Generators versus Coroutines

Michael Sparks zathras at thwackety.com
Wed Aug 18 07:08:01 EDT 2004


On 17 Aug 2004, Bryan Olson wrote:
...
> Have you been badly bitten by an evil co-routine?

You appear to misunderstand what I was saying. I was not saying
co-routines are bad. I was saying that generators are, in my experience,
almost as effective. This isn't attacking anything. It's saying that
generators really aren't as bad as it appears some people make out.

As for network servers, it looks like the network server system based on
using generators to gain most of the benefits of co-routines I briefly
talked about (in one of the lightning talks) at EuroPython has been
blocked for release as open source :-(

Your arguments in favour of co-routines for servers all hold (IME) for
generators as well. There is _slight_ extra obfuscation, but nowhere near
the level of change required for event processing.

NB. The reason I like generators is because they allow me to do
co-routine-type things in python with no addons. The reason I like
greenlets is because it seems to go much, much, much further along
that route _and_ gives a performance boost. Also, I'm not opposed to
co-routines being added to the language *if* it was done in a manner
that doesn't confuse new users, however greenlets appear to mitigate
that requirement.

Best Regards,


Michael.




More information about the Python-list mailing list