[Python-ideas] PEP 530: Asynchronous Comprehensions

Sven R. Kunze srkunze at mail.de
Tue Sep 6 11:20:41 EDT 2016


On 06.09.2016 03:16, Yury Selivanov wrote:
>
>> Whereas the following will produce some sort of async lists, sets, 
>> and dicts?
>>
>>>     result = [await fun() async for fun in funcs]
>>>     result = {await fun() async for fun in funcs}
>>>     result = {fun: await fun() async for fun in funcs}
>>
>> If so, how do I read values from an async list/set/dict?
>
> Consider "funcs" to be an asynchronous generator/iterable that 
> produces a sequence of awaitables.  The above comprehensions will 
> await on each awaitable in funcs, producing regular list, set, and dict.

So, what's the "async" good for then?


> I doubt that anybody ever would write something like that; this is 
> just examples of what the PEP will enable.

Why do you implement it then? :D
Put it differently, why are you sceptic about it?


> There is no concept of asynchronous datastructures in Python.

I thought so, that's why I asked. ;) "async def" gives me something 
async, so I assumed it to be the case here as well.


Cheers,
Sven


More information about the Python-ideas mailing list