fiber(cooperative multi-threading)

Duncan Booth duncan.booth at invalid.invalid
Sat Dec 22 09:37:25 EST 2007


Arnaud Delobelle <arnodel at googlemail.com> wrote:

> I am not really familiar with ruby but these fibers seem to be some
> sort of coroutines.  Since python 2.5, generators can be sent values,
> this can be used to implement what you want.  I have had a got at it
> for fun and this is what I came up with: note that there is no need
> for a specific class, or for threads.  I have tested this only on your
> example, but it gives the same result as your code :)

I think it was Microsoft who invented the term 'fiber' as a synonym for 
coroutine. See http://msdn2.microsoft.com/en-us/library/ms682661.aspx

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 
http://codespeak.net/py/dist/greenlet.html




More information about the Python-list mailing list