"Ian Kelly" wrote in message news:CALwzid=hrijtv4p1_6frkqub25-o1i8ouquxozd+aujgl7+...@mail.gmail.com...

On Wed, Nov 30, 2016 at 1:29 AM, Frank Millman <fr...@chagford.com> wrote:
>
> async def anext(aiter):
>    return await aiter.__anext__()

Even simpler:

def anext(aiter):
    return aiter.__anext__()

As a general rule, if the only await in a coroutine is immediately
prior to the return, then it doesn't need to be a coroutine. Just
return the thing it's awaiting so that the caller can be rid of the
middle man and await it directly.

Fascinating!

Now I will have to go through all my code looking for similar occurrences. I am sure I will find some!

Frank


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to