[Python-ideas] Coroutines and PEP 380

Paul Moore p.f.moore at gmail.com
Wed Jan 25 19:47:06 CET 2012

On 25 January 2012 14:45, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Do you mean preemptive coroutines as opposed to ("yield from"-based)
> cooperative coroutines?

My understanding (in general, and specifically of the various
discussions that have happened on python-ideas) is that we're talking
about co-operative coroutines.

To be clear, what I mean by that is that a coroutine switch is invoked
by an explicit call/statement (which may be "yield from" or some
as-yet unspecified variation - a cocall statement, a call to a
switch() method on a coroutine object, or whatever). The discussions
seem to be more about whether incrementally extending generators (with
send methods, yield from, etc) to turn them into coroutines is better
or worse than starting with a new approach which is closer to
"conventional" approaches from other languages with first-class
coroutines (for example Lua, which uses method calls on coroutine

I presume that "preemptive coroutines" means that a coroutine switch
can occur at any point. I can't see how that is in any practical sense
different from a thread...


More information about the Python-ideas mailing list