Author yselivanov
Recipients asvetlov, ericvw, gvanrossum, levkivskyi, pablogsal, serhiy.storchaka, yselivanov
Date 2018-05-14.18:47:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>

> 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.


> @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:06yselivanovsetrecipients: + yselivanov, gvanrossum, ericvw, asvetlov, serhiy.storchaka, levkivskyi, pablogsal
2018-05-14 18:47:06yselivanovsetmessageid: <>
2018-05-14 18:47:06yselivanovlinkissue33346 messages
2018-05-14 18:47:06yselivanovcreate