[pypy-dev] Extension Modules Re: Question on Hard Switching and Soft Switching

Richard Tew richard.m.tew at gmail.com
Sun Oct 4 22:36:34 CEST 2009

On Mon, Oct 5, 2009 at 12:42 AM, Armin Rigo <arigo at tunes.org> wrote:
> Stackless aside.  I fear that we don't want to spend much time improving
> Stackless support right now, but you are welcome to try and contribute
> e.g. a modification to the '_select' module to optionally use,
> internally, non-blocking sockets and be Stackless-aware in a
> user-transparent manner.  (Such a module can even be written in plain
> Python and be portable across Stackless Python and Stackless PyPy.  It
> might even already have been written for Stackless Python; you should
> look around.)

While I also agree that low-level support like a beneficial idea, in
practice I have my doubts about it.

When you write low-level modules which work with Stackless, they make
assumptions about how they should work with the scheduler.  These
assumptions may not match how the user is running the scheduler at a
higher level.  For instance, in the CCP framework you cannot loop over
'stackless.schedule' as tasklets are expected to yield out of the
scheduler onto a channel.

In any case, select would not be the right place.  It is where someone
goes to work with asynchronous IO.  I would rather suggest that the
uber-module would be the socket module, and that behind the scenes it
might use IO completion ports on Windows and poll or something similar
on other platforms.  But the goal in doing it, would be to make IO
just work with a microthread scheduling framework for the user with
minimal difficulty or effort.  In order for this to be so, how it
works with the scheduler would have to be equally simple for the user.


More information about the Pypy-dev mailing list