Victor, I mean replacing
def consume_coroutine():
coro = coroutine(5)
try:
next(coro)
except StopIteration as exc:
return exc.value
else:
raise Exception("StopIteration not raised?")
with
def consume_coroutine():
yield from coroutine(5)
return
reduces performance degradation from initial 450% to 150% comparing to
synchronous code.
I can live with the last result.
On Wed, Feb 11, 2015 at 6:16 PM, Ben Darnell <[email protected]> wrote:
> On Wed, Feb 11, 2015 at 10:01 AM, Victor Stinner <[email protected]>
> wrote:
>>
>> By the way, Trollius has currently the performance issue of recursive
>> coroutines. It doesn't use yield-from and it currently creates a new
>> task for each sub-coroutine. I read somewhere that Tornado solved this
>> issue by following coroutines instead of treating them independently.
>> We can probably implement the same optimization strategy in trollius.
>
>
> Tornado still creates a new Runner for each nested coroutine, so it is
> slower than yield-from. You might be thinking of the fact that we bypass the
> Runner for cases where a coroutine completes in a single pass (i.e. without
> executing any yields).
>
> -Ben
--
Thanks,
Andrew Svetlov