
On 06.09.2016 19:38, Yury Selivanov wrote:
On 2016-09-06 9:40 AM, C Anthony Risinger wrote:
On Tue, Sep 6, 2016 at 10:20 AM, Sven R. Kunze <srkunze@mail.de <mailto:srkunze@mail.de>> wrote:
So, what's the "async" good for then?
Maybe I'm off base here, but my understanding is the `async for` version would allow for suspension during the actual iteration, ie. using the __a*__ protocol methods, and not just by awaiting on the produced item itself.
IOW, `[await ... async for ...]` will suspend at least twice, once during iteration using the __a*__ protocols and then again awaiting on the produced item, whereas `[await ... for ...]` will synchronously produce items and then suspend on them. So to use the async + await version, your (async) iterator must return awaitables to satisfy the `async for` part with then produce another awaitable we explicitly `await` on.
Can someone confirm this understanding? And also that all 4 combinations are possible, each with different meaning:
# Normal comprehension, 100% synchronous and blocking [... for ...]
# Blocking/sync iterator producing awaitables which suspend before producing a "normal" value [await ... for ...]
# Non-blocking/async iterator that suspends before producing "normal" values [... async for ...]
# Non-blocking/async iterator that suspends before producing awaitables which suspend again before producing a "normal" value [await ... async for ...]
Is this correct?
All correct. I'll update the PEP to better clarify the semantics.
Still don't understand what the "async" is good for. Seems redundant to me. Sven