[Python-ideas] Cofunctions - Back to Basics

Mark Shannon mark at hotpy.org
Thu Oct 27 13:39:48 CEST 2011


Greg Ewing wrote:
> Mark Shannon wrote:
> 
>> Why not have proper co-routines, instead of hacked-up generators?
> 
> What do you mean by a "proper coroutine"?
> 

A parallel, non-concurrent, thread of execution.
It should be able to transfer control from arbitrary places in 
execution, not within generators.

Stackless provides coroutines. Greenlets are also coroutines (I think).

Lua has them, and is implemented in ANSI C, so it can be done portably.
See: http://www.jucs.org/jucs_10_7/coroutines_in_lua/de_moura_a_l.pdf

(One of the examples in the paper uses coroutines to implement 
generators, which is obviously not required in Python :) )

Cheers,
Mark.





More information about the Python-ideas mailing list