[Python-ideas] yield from multiple iterables (was Re: The async API of the future: yield-from)
jimjjewett at gmail.com
Tue Oct 23 09:17:01 CEST 2012
On 10/19/12, Guido van Rossum <guido at python.org> wrote:
> I did a basic timing test using a simple recursive function and a
> recursive PEP-380 coroutine computing the same value (see attachment).
> The coroutine version is a little over twice as slow as the function
> version. I find that acceptable. This went 20 deep, making 2 recursive
> calls at each level (except at the deepest level).
Note that the co-routine code (copied below) does not involve a
scheduler that unwraps futures; there is no scheduler, and nothing
if n <= 0:
l = yield from coroutine(n-1)
r = yield from coroutine(n-1)
return l + 1 + r
I like the above code; my concern was that yield might get co-opted
for use with scheduler loops, which would have to track the parent
task explicitly, and prevent it from being rescheduled too early.
More information about the Python-ideas