[Python-Dev] Coroutines (PEP 342)

Donovan Baarda abo at minkirri.apana.org.au
Tue Nov 15 10:25:29 CET 2005

On Mon, 2005-11-14 at 15:46 -0700, Bruce Eckel wrote:
> What is not clear to me, and is not discussed in the PEP, is whether
> coroutines can be distributed among multiple processors. If that is or
> isn't possible I think it should be explained in the PEP, and I'd be
> interested in know about it here (and ideally why it would or wouldn't
> work).

Even if different coroutines could be run on different processors, there
would be nothing gained except extra overheads of interprocessor memory
duplication and communication delays.

The whole process communication via yield and send effectively means
only one co-routine is running at a time, and all the others are blocked
waiting for a yield or send.

This was the whole point; it is a convenient abstraction that appears to
do work in parallel, while actually doing it sequentially, avoiding the
overheads and possible race conditions of threads.

It has the problem that a single co-routine can monopolise execution,
hence the other name "co-operative multi-tasking", where co-operation is
the requirement for it to work.

At least... that's the way I understood it... I could be totally

Donovan Baarda <abo at minkirri.apana.org.au>

More information about the Python-Dev mailing list