Yury Selivanov <[email protected]> added the comment:
[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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33346>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com