Revisiting Generators and Subgenerators

Winston Wolff winstonw at stratolab.com
Fri Mar 26 01:31:24 CET 2010


Coroutines achieve very similar things to threads, but avoid problems resulting from the pre-emptive nature of threads. Specifically, a coroutine indicates where it will yield to the other coroutine. This avoids lots of problems related to synchronization. Also the lightweight aspect is apparently important for some simulations when they have many thousands of agents to simulate--this number of threads becomes a problem.

-Winston

Winston Wolff
Stratolab - Games for Learning
tel: (646) 827-2242
web: www.stratolab.com

On Mar 25, 2010, at 5:23 PM, Cameron Simpson wrote:

> 
> Having quickly read the Abstract and Motivation, why is this any better
> than a pair of threads and a pair of Queue objects? (Aside from
> co-routines being more lightweight in terms of machine resources?)
> 
> On the flipside, given that generators were recently augumented to
> support coroutines I can see your motivation within that framework.
> 
> Cheers,
> -- 
> Cameron Simpson <cs at zip.com.au> DoD#743
> http://www.cskk.ezoshosting.com/cs/
> 
> C makes it easy for you to shoot yourself in the foot.  C++ makes that
> harder, but when you do, it blows away your whole leg.
> - Bjarne Stroustrup




More information about the Python-list mailing list