[Python-Dev] Trial balloon: microthreads library in stdlib

Richard Tew richard.m.tew at gmail.com
Sun Feb 11 20:05:35 CET 2007


On 2/11/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> Brett Cannon schrieb:
> >> Of course Stackless isn't quite fully integrated with 2.5 (yet).
> >>
> >> When did someone last suggest that Stackless become part of the core
> >> CPython implementation, and why didn't that ever happen?
> >>
> >
> > Don't remember the "when".  The "why" has always been that Christian's
> > hacks into the core were complicated and he didn't even think
> > integration was worth it.
>
> With emphasis on the latter. Christian never proposed (to my knowledge)
> that Stackless should be integrated. Of course, he didn't propose it
> because he assumed that proposal would be turned down, anyway.

As I understand it, given that at that time continuations and actually
trying to make Python stackless were a goal of Stackless Python,
I would hope people do not assume that the changes it currently
makes to the core are the same as the ones mentioned here as
hacks.

Both of these goals have been discarded and Christian also made it
an aim to make very few changes to the core and to "keep it and
Stackless' intersection a minimum".

One improvement Stackless needs related to what is proposed
for the generator coroutines, is wrapping calls out of the Python
runtime to things like network and file IO, so that microthreads
can naturally take advantage of them.  The asyncore module does
the job for socket IO and allows monkeypatching the socket
module so that the current microthread blocks on the
asynchronous IO so the scheduler can continue without the
whole runtime being stalled.  But there is no support for cross-
platform (specifically on Windows) asyncronous file IO for instance.

If these generator coroutine microthreads went ahead and part
of it was improving the support for asynchronous calls in the
runtime and standard library, this would also be something
which also benefited Stackless Python.  Even if they didn't go
ahead I would be interested in hearing about whether these
sort of changes would be of interest or not for whatever reason.

Regarding the port of Stackless to 2.5, it passes both its own
(albeit limited) set of tests and the core's set as well.  And there
are no known bugs which affect general usage.

Hope this helps,
Richard.


More information about the Python-Dev mailing list