Message316549
[Serhiy]
> But asynchronous comprehensions should behave the same way as 'await'. I think that a comprehension should be made implicitly asynchronous if any of inner expressions contains explicit or implicit asynchronous comprehension. This is implemented in PR 6766.
[Guido]
> @Yury: Your thoughts?
> I do think the code from the OP's example should be expected to work.
I agree with Serhiy and I like his proposal. Essentially, a comprehension is asynchronous when it contains an "await" or an "async for" in it. We want to add another case: make it async when any of its inner-expressions is an async comprehension. Essentially:
[f: [x async for x in f(x)] for f in fs]
The nested comprehension is obviously asynchronous, so the outer comprehension should become asynchronous too. I think this is a fairly obvious and easy to follow semantics.
Guido, if you agree that this is a reasonable proposition I can update PEP 530 about this new behaviour (for Python 3.8) and review Serhiy's PR. |
|
Date |
User |
Action |
Args |
2018-05-14 18:47:06 | yselivanov | set | recipients:
+ yselivanov, gvanrossum, ericvw, asvetlov, serhiy.storchaka, levkivskyi, pablogsal |
2018-05-14 18:47:06 | yselivanov | set | messageid: <1526323626.88.0.682650639539.issue33346@psf.upfronthosting.co.za> |
2018-05-14 18:47:06 | yselivanov | link | issue33346 messages |
2018-05-14 18:47:06 | yselivanov | create | |
|