Generators versus Coroutines

Bryan Olson bryanjugglercryptographer at yahoo.com
Mon Aug 16 20:08:39 EDT 2004


Michael Sparks:
> On Sun, 15 Aug 2004, Nick Patavalis wrote:
> ...
> > For me it would be *tremendously* usefull if one could yield across
> > multiple levels of function calls. If this was supported, then most
> > uses of O/S treads could be replaced by generators.
> 
> You can do this already if you use Armin Rigo's Greenlets which, whilst
> included in Stackless appear to work perfectly fine with standard python.
> (I've only tested with 2.3 FWIW)

Correct me if I'm wrong: Greenlets use a c-language extension to
do the routine switching; implementing the same in pure Python is
infeasable.

Generators rock, but they have a shadow of the power of co-routines.
Continuations are more powerful still.

-- 
--Bryan



More information about the Python-list mailing list