[Python-ideas] async/await in Python

Yury Selivanov yselivanov.ml at gmail.com
Sat Apr 18 19:04:54 CEST 2015


Hi Todd,

On 2015-04-18 6:41 AM, Todd wrote:
> On Apr 17, 2015 8:59 PM, "Yury Selivanov" <yselivanov.ml at gmail.com> wrote:
>> <snip>
>>
>>      async with EXPR as VAR:
>>          BLOCK
>>
>>
>>   <snip>
>>
>>      async for TARGET in ITER:
>>          BLOCK
>>      else:
>>          BLOCK2
>>
> Is this really something that should restricted to async?  I could see
> similar syntax being useful for multithreading, multiprocessing, MPI, etc.
> What about a more general language feature, where any class implementing
> certain magic methods could be used in this way?

Coroutines in PEP 492 is a generic concept, completely
framework agnostic.  Any class can implement the methods,
coroutines can be used in any way you like.

asyncio users will definitely take full advantage of new
syntax, but nothing prevents others to create new libraries
and invent new use cases.

Thanks,
Yury


More information about the Python-ideas mailing list