[Stackless] Link to Stackless.py with select

Andrew Francis andrewfr_ice at yahoo.com
Thu Jun 10 15:21:09 CEST 2010

Hello Richard:

I greatly appreciate your comments.

>Superficially.. The list passed to 'select' is superfluous, you can
>just pass N arguments and use *args to make a list internally.

This didn't occur to me. My intent was if the list is constantly 
reused, as in an event loop, we don't want to constantly rebuild it. Also
it is easier to dynamically add and remove channels from a list. 

>Obtaining a reference to the current tasklet is not the most natural
>operation.  Having 'select' on the stackless module might be better.

I see your point. However I think having select() as a tasklet 
method makes it easier to cache or persist state. I have to verify
this with pickling tests. Maybe I am viewing things wrong.

>Looking at your code, with special 'sendCase' and 'receiveCase'
>methods, required use of an if statement or dictionary to dispatch the
>result of the operation and so on.  What this says to me is that
>'select' is not a natural fit for Python.  The other languages I have
>seen it in, have language syntax that accompanies it which makes it a
>natural part of the given language.  Special operators and things like

The bottom line is Python does not have a switch statement. I believe Philip Eby has experimented with that construct. If I can figure out the PyPy interpreter, I would like to model this as a language feature but I have my reservations about how useful select() is as a language feature. 

I feel that even with ifs/hash tables, code using a select() has better structure and gives more flexibility than its Go equivalent.

>An area for further experimentation might be to take a look at the
>"goto" addition to Python and see if you can add a custom syntax that
>might bring this to a more natural level in Python.

I have to disagree there. No "gotos" :-)

Once again, I appreciate your comments. Let me prototype a new version with
those changes and see how it flies. 



More information about the Stackless mailing list