[Python-ideas] Asynchronous friendly iterables

Joao S. O. Bueno jsbueno at python.org.br
Mon Aug 20 09:53:17 EDT 2018


On Mon, 20 Aug 2018 at 04:49, Chris Angelico <rosuav at gmail.com> wrote:
>
> On Mon, Aug 20, 2018 at 5:34 PM, Simon De Greve <degrevesim at gmail.com> wrote:
> > Do you mean that for loops inside an "async def" statements are always
> > executed as 'async for' loops? That's what I wanted to acheive by writing
> > the AsyncDict class (c.f. the CodeReview link).
>
> The point of an 'async for' loop is that grabbing the next value can
> block the async function - it's a yield point. If you don't need that,
> you can use a regular 'for' loop.

Maybe it is worth to further clarify that iterating on dicts and lists
is _not_ blocking at all.
That would only be the case if to retrieve its own keys the dictionary
would have
to perform some I/O access or heavy computation - which, besides been of very
little value in practice, would only be possible in a specialized class anyway.


>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/


More information about the Python-ideas mailing list