[Python-Dev] PEP 492: async/await in Python; v3

Walter Dörwald walter at livinglogic.de
Tue Apr 28 16:23:31 CEST 2015


On 28 Apr 2015, at 5:07, Yury Selivanov wrote:

> Hi python-dev,
>
> Another round of updates.  Reference implementation
> has been updated: https://github.com/1st1/cpython/tree/await
> (includes all things from the below summary of updates +
> tests).
>
> [...]
> New Coroutine Declaration Syntax
> --------------------------------
>
> The following new syntax is used to declare a coroutine::
>
>  async def read_data(db):
>      pass
>
> Key properties of coroutines:
>
> * ``async def`` functions are always coroutines, even if they do not
> contain ``await`` expressions.
>
> * It is a ``SyntaxError`` to have ``yield`` or ``yield from``
> expressions in an ``async`` function.

Does this mean it's not possible to implement an async version of 
os.walk() if we had an async version of os.listdir()?

I.e. for async code we're back to implementing iterators "by hand" 
instead of using generators for it.

> [...]

Servus,
    Walter


More information about the Python-Dev mailing list