Generators versus Coroutines

Dominic nomail at nospam.no
Wed Aug 18 04:19:48 EDT 2004


> I've seen servers that rock written with explicit event handling,
> threads, processes, and occasionally co-routines.  Where are the
> great generator-based servers?
Well, the Erlang (language + telecom platform) uses light-weight
threads which could e.g. be implemented with coroutines in Python.
   Event handling is fine but you could also explicitly code
your behaviour as state machines ;-) The drawback of event
handling is that you have to separate state and control flow
and resuming is error prone whereas generators and coroutines
are easier and feel more natural. Especially in simulations
where you need lots of active entities, there is hardly a
way around light-weight and deterministic concurrency.
Take the SIMULA language as an example for the
combination of simulation and coroutines.

Ciao,
  Dominic



More information about the Python-list mailing list