[Python-ideas] PEP 525: Asynchronous Generators

Alexander Shorin kxepal at gmail.com
Fri Aug 5 16:34:19 EDT 2016


Hi Yury!

Thanks for this PEP! This is really what asyncio misses since you made
async iterators.

As contributor to aiohttp and maintainer of aiocouchdb and few else
projects I also support this PEP. Great one!

I agree with what Nikolay and Andrew already said: dancing
around__aiter__/__anext__ to emulate genarator-like behaviour is quite
boring and complicated. This also makes porting "old synced" code onto
asyncio harder since you have to rewrite every generator in iterator
fashion and wrap each with an object that provides __aiter__ /
__anext__ interface.

For the reference I have is ijson PR[1] that adds asyncio support. If
we forget about compatibility with 3.3/3.4, with async generators the
result implementation would be much more elegant and looks more closer
to the original synced code, because it's all based on generators.

Lack of async generators forces people to implement them on their own
[2] ones[3], not very effective as the one that could be built-in.
Also custom interface for each implementation makes hardly to reuse
them and don't even imagine what happens if two custom async generator
implementations will met in a single project.

So thank you again, Yury, for pushing this really important and
missing feature forward!

[1]: https://github.com/isagalaev/ijson/pull/46
[2]: https://github.com/germn/aiogen
[3]: https://github.com/ethanfrey/aiojson/blob/master/aiojson/utils/aiogen.py

-- 
,,,^..^,,,


More information about the Python-ideas mailing list