[Stackless] Multi-CPU Actor Based Python

Michael ms at cerenity.org
Tue Nov 18 22:26:59 CET 2008

On Tuesday 18 November 2008 20:33:24 Timothy Baldridge wrote:
> but passing messages in between
> objects. If we can get a framework to match this model, I think it
> could be quite usable.

Stackless essentially does that in the form of tasklets using channels. 
Kamaelia also does something similar, but uses lists for generators, 
Queue.Queue's for threads, the os.pipes for (pickled) objects between 
processes. (kamaelia works with standard cpython) 

Kamaelia gives you a component model instead based around message passing, and 
a different component base class for different concurrency mechanisms. At 
some point I'd like to have tasklet based components as well (which would 
therefore naturally use channels for comms in the a similar way to lists, 
Queues, os.pipes are used for the other mechanisms).

The biggest problem you're hitting conceptually between the shift between 
erlang and other languages, is that Erlang is a functional language, and 
python isn't. In a functional language you're doing everything by value, 
whereas in python everything is essentially by reference. (I've not used 
erlang, but I have written large programs in SML, which also a functional 

Now, the principles of shared nothing and message passing can be implemented 
in Python and non-functional languages, and you can get very high scalability 
(cf eve online in Stackless for example), but your model won't be *identical* 
to Erlang, because it can't be - Python is fundamentally built on mutable 
types, whereas Erlang is fundamentally functional and built on immutable 

The flipside, which the Reia people are doing is to try and implement a 
python-like syntax on top of the Erlang VM, which I find particularly 
interesting - http://wiki.reia-lang.org/

Going back to the part I quoted though:
> but passing messages in between objects. If we can get a framework to match
> this model, I think it  could be quite usable.

Based on my work on Kamaelia I believe it is extremely usable (we've also
tested it's accessibility against a variety of levels of experience - novice
upwards). You may also want to look at the list of Actor implementations for 
   * http://dramatis.mischance.net/
   * http://osl.cs.uiuc.edu/parley/
   * http://tinyurl.com/5xd87k 

Kamaelia isn't quite the same as the actor model btw since you send to a local
outbox, rather than to a recipient's inbox. Something else joins the dots at a
higher level, which then under the hood actually means sending to an outbox is
instantly delivered to the appropriate inbox, so it should have similar

But then you could easily implement something similar in stackless, since 
stackless's model is very similar. The place to start with that would 
probably be to do our http://www.kamaelia.org/MiniAxon/ tutorial, but
using tasklets instead of generators, and channels instead of lists.



More information about the Stackless mailing list