Duncan Booth wrote: > Unfortunately generators only save a single level of stack-frame, so they > are not really a replacement for fibers/coroutines. The OP should perhaps > look at Stackless Python or Greenlets. See
On the surface of things, the single level aspect *LOOKS* like a problem, but in fact is actually really useful. The reason is because it encourages a generator to be relatively simple and focused encouraging reuse. cf the components listed here: * http://kamaelia.sourceforge.net/Components Also, because they're simple, you can link every component in that list either directly with all the others or via a trivial filtering component. Also the fact that you have to build your own scheduler means you can do the equivalent of saying to the scheduler "Don't run me next, run this next". This gives you pretty much the full power of co-routines but allows for very heavy reusability and independence of testing. An example application that makes moderate use of this "bounce back" coroutines is a greylisting server you can find here: * http://kamaelia.sourceforge.net/KamaeliaGrey I'd (almost) argue that the single level aspect of generators is perhaps their best feature. Michael. -- http://yeoldeclue.com/blog http://kamaelia.sourceforge.net/Developers/ -- http://mail.python.org/mailman/listinfo/python-list