[Python-3000] Futures in Python 3000

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Apr 21 11:33:10 CEST 2006


Andy Sy wrote:

> Huh?  Futures are very different from continuations.  I still have a
> hard time understanding continuations (and am no fan of them), but
> futures seem to be a rather simple abstraction to comprehend.

Isn't a future just a coroutine, or something equivalent?

Sometimes there's a bit of confusion when people use the terms
"coroutine" and "continuation" interchangeably. They're not
quite the same thing. True continuations can be "resumed"
more than once from the same state, whereas a coroutine can
only be resumed once, after which its state has changed.

This makes true continuations a good deal more complicated
to implement, *unless* you've planned your entire language
implementation from the outset with support for them in mind.
CPython was *not* so designed.

Coroutines are somewhat easier, but still present considerable
difficulties for an implementation that works the way CPython
does. Researching the history of Stackless will show why.

Attempting to channel Guido a bit here, I'd say he also
means that Py3k will not have *coroutines* either, or anything
equivalent to coroutines, except insofar as they are provided
by the operating system in the form of threads. Generators
already go as far as it is possible to go into coroutine-land
without unacceptably large changes to the implementation.

--
Greg


More information about the Python-3000 mailing list