On 10/19/12, Guido van Rossum <guido@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 runs concurrently. def coroutine(n): if n <= 0: return 1 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. -jJ