osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Addendum to PEP 530


PEP 530 introduced support for asynchronous comprehensions.

Comprehensions are implemented as local functions. To make a function 
asynchronous you should to add "async" before "def", and after that you 
can use "async for", "async with" and "await" in a function. But you can 
to do this with comprehensions, since these functions are implicit.

PEP 530 allows to make these function asynchronous by just using 
asynchronous syntax inside. "async with" can not be used in 
comprehensions, but using "async for" or "await" makes the comprehension 
asynchronous.

What PEP 530 missed is that asynchronous comprehensions itself are 
asynchronous constructions which can be used only in asynchronous functions.

Issue33346 [1] makes an asynchronous comprehension inside a 
comprehension making the outer comprehension asynchronous as well as 
using explicit "async for" or "await". See details on the issue.

Yury, the author of PEP 530, likes this idea, and there is a ready 
implementation. But making the decision was deferred until a new 
government be stated. Now, after the Steering Council has been elected, 
can it make the decision?

[1] https://bugs.python.org/issue33346