Stronger async neutral iter
?
#77
Replies: 2 comments 1 reply
-
Where to put the new functionality?There is an important point against extending That is only possible for the flat Using a separate tool such as |
Beta Was this translation helpful? Give feedback.
-
What cases to cover?Obviously we should cover at least the cases of the default The motivating case is We actually also have an additional case, already handled by I don't think cases like I see some value in having "async flattening", e.g. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
builtins.iter
and most things using it (or its underlying helper) currently accept bothIterable
andAsyncIterable
to be "async neutral". However, there is an additional case ofAwaitable[Iterable]
that is not handled.builtins.iter
support this case?This case can easily occur when working with functions that may be either a generator or return an iterable. In the sync case, both of these are very similar – we can fetch the values from either via any iterable-consumer, such as
list
:In the async case, the two are in fact very different. One is an
Awaitable[Iterator]
that requiresfor ... in await x
and the other is anAsyncIterator
that requiresasync for ... in x
.Beta Was this translation helpful? Give feedback.
All reactions