[Python-Dev] Coroutines and PEP 380
mark at hotpy.org
Wed Jan 18 10:23:49 CET 2012
> On Jan 17, 2012, at 5:03 PM, Mark Shannon wrote:
>> Lets start controversially: I don't like PEP 380, I think it's a kludge.
> Too late; it's already accepted. There's not much point in making
> controversial statements about it now.
Why is it too late? Presenting this as a fait accompli does not make it
any better. The PEP mailing list is closed to most people, so what forum
for debate is there?
>> I think that CPython should have proper coroutines, rather than add
>> more bits and pieces to generators in an attempt to make them more
>> like coroutines.
> By "proper" coroutines, you mean implicit coroutines (cooperative
> threads) rather than explicit coroutines (cooperative generators).
Nothing "implicit" about it.
> Python has been going in the "explicit" direction on this question for
> a long time. (And, in my opinion, this is the right direction to go,
> but that's not really relevant here.)
You can use asymmetric coroutines with a scheduler to provide
cooperative threads if you want, but coroutines not have to be used as
The key advantages of my coroutine implmentation over PEP 380 are:
1. No syntax change.
2. Code can be used in coroutines without modification.
3. No stack unwinding is required at a yield point.
> I think this discussion would be more suitable for python-ideas though,
> since you have a long row to hoe here. There's already a PEP -
> http://www.python.org/dev/peps/pep-0219/ - apparently deferred and not
> rejected, which you may want to revisit.
> There are several libraries which can give you cooperative threading
> already; I assume you're already aware of greenlet and stackless, but I
> didn't see what advantages your proposed implementation provides over
> those. I would guess that one of the first things you should address on
> python-ideas is why adopting your implementation would be a better idea
> than just bundling one of those with the standard library :).
Already been discussed:
All of the objections to coroutines (as I propose) also apply to PEP 380.
The advantage of my implementation over greenlets is portability.
I suspect stackless is actually fairly similar to what I have done,
I haven't checked in detail.
More information about the Python-Dev