[Python-ideas] More general "for" loop handling

Yury Selivanov yselivanov.ml at gmail.com
Fri May 1 03:07:50 CEST 2015


On 2015-04-30 9:02 PM, Ethan Furman wrote:
> On 04/30, Yury Selivanov wrote:
>> On 2015-04-30 8:35 PM, Steven D'Aprano wrote:
>>> I don't think it guarantees ordering in the sense I'm referring to. It
>>> guarantees that the returned result will be [f(a), f(b), f(c), ...] in
>>> that order, but not that f(a) will be calculated before f(b), which is
>>> calculated before f(c), ... and so on. That's the point of parallelism:
>>> if f(a) takes a long time to complete, another worker may have completed
>>> f(b) in the meantime.
>> This is an *excellent* point.
> So, PEP 492 asynch for also guarantees that the loop runs in order, one at
> a time, with one loop finishing before the next one starts?
>
> *sigh*
>
> How disappointing.
>


No.  Nothing prevents you from scheduling asynchronous
parallel computation, or prefetching more data.  Since
__anext__ is an awaitable you can do that.

Steven's point is that Todd's proposal isn't that
straightforward to apply.


Yury


More information about the Python-ideas mailing list