[Python-ideas] PEP 525: Asynchronous Generators

Yury Selivanov yselivanov.ml at gmail.com
Fri Aug 5 12:39:59 EDT 2016


On 2016-08-05 11:11 AM, Andrew Svetlov wrote:
> As maintainer of aiohttp (asyncio-compatible HTTP client/server) and 
> aiopg (PostgreSQL asyncio driver) I totally support the pep.
>
> The problem is: I'm able to write async iterator class which utilizes 
> __aiter__/__anext__.
> But users of my libraries are not.
>
> Writing synchronous generator functions for data processing is very 
> common pattern.
>
> But class based approach requires saving all context not in local 
> variables but in instance vars, you know.
>
> It's a nightmare in practice, as consequence people writes more 
> complex and error prone code than they could write with this PEP.
>
> https://www.python.org/dev/peps/pep-0255/ for simple generators is 15 
> years old, I believe everybody understand why we need it.

Thanks, Andrew!  Your feedback is coming from a deep experience of 
working with asyncio, therefore it's extremely valuable!

Yury


More information about the Python-ideas mailing list