[Python-Dev] async/await in Python; v2

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Apr 22 08:05:19 CEST 2015


Yury Selivanov wrote:
> 1. CO_ASYNC flag was renamed to CO_COROUTINE;
> 
> 2. sys.set_async_wrapper() was renamed to
>    sys.set_coroutine_wrapper();
> 
> 3. New function: sys.get_coroutine_wrapper();
> 
> 4. types.async_def() renamed to types.coroutine();

I still don't like the idea of hijacking the generic
term "coroutine" and using it to mean this particular
type of object.

> 2. I propose to disallow using of 'for..in' loops,
>    and builtins like 'list()', 'iter()', 'next()',
>    'tuple()' etc on coroutines.

PEP 3152 takes care of this automatically from the fact
that you can't make an ordinary call to a cofunction,
and cocall combines a call and a yield-from. You have
to go out of your way to get hold of the underlying
iterator to use in a for-loop, etc.

-- 
Greg



More information about the Python-Dev mailing list