[Python-Dev] async/await in Python; v2 (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Thu Apr 23 08:37:28 CEST 2015
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
PJ Eby wrote:
I find this a little weird. Why not just have
with
andfor
inside a coroutine dynamically check the iterator or context manager, and either behave sync or async accordingly? Why must there be a syntactic difference?
It depends on whether you think it's important to have a syntactic marker for points where the code can potentially be suspended.
In my original vision for PEP 3152, there was no "cocall" syntax -- you just wrote an ordinary call, and whether to make a cocall or not was determined at run time. But Guido and others felt that it would be better for suspension points to be explicit, so I ended up with cocall.
The same reasoning presumably applies to asynchronous 'for' and 'with'. If you think that it's important to make suspendable calls explicit, you probably want to mark them as well.
...which, incidentally, highlights one of the things that's been bothering me about all this "async foo" stuff: "async def" looks like it defines the function asynchronously
That bothers me a bit, too, but my main problem with it is the way it displaces the function name. "def f() async:" would solve both of those problems.
-- Greg
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]