pep-0492: 'Why not reuse existing "for" and "with"...' section
This commit is contained in:
parent
8935feb87c
commit
2feb4ad5c3
14
pep-0492.txt
14
pep-0492.txt
|
@ -754,13 +754,13 @@ Differences from this proposal:
|
|||
6. Requiring parentheses grammatically also introduces a whole lot
|
||||
of new problems.
|
||||
|
||||
Code like the following::
|
||||
The following code::
|
||||
|
||||
await fut
|
||||
await function_returning_future()
|
||||
await asyncio.gather(coro1(arg1, arg2), coro2(arg1, arg2))
|
||||
|
||||
would look like::
|
||||
would look like::
|
||||
|
||||
cocall fut() # or cocall costart(fut)
|
||||
cocall (function_returning_future())()
|
||||
|
@ -951,6 +951,16 @@ This approach has the following downsides:
|
|||
simple and foolproof as possible.
|
||||
|
||||
|
||||
Why not reuse existing "for" and "with" statements
|
||||
--------------------------------------------------
|
||||
|
||||
The vision behind existing generator-based coroutines and this proposal
|
||||
is to make it easy for users to see where the code might be suspended.
|
||||
Making existing "for" and "with" statements to recognize asynchronous
|
||||
iterators and context managers will inevitable create invisible
|
||||
implicit suspend points, making it harder to reason about the code.
|
||||
|
||||
|
||||
Comprehensions
|
||||
--------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue