Python Desktop Server Weblog 4.1.2005

a picture of myself

Münsterland.org

2005-01-04

Continuations with Python

In my quest to do the most stupid and outright silly things possible with Python, I dived into the problem of continuations. This was triggered by me playing with Seaside2 for Smalltalk, a rather cool web framework that makes heavy use of continuations.

So I checked what options I have for continuations in Python. Looks like I am out in the colde - the Stackless guy dropped continuations in his work and concentrates on micro threads and stuff like that. Normal CPython doesn't have anything resembling continuations at all.

But what are threads actually other than just special forms of continuations? You can build threads, coroutines, exception handling, generators and stuff like that with continuations - can we do it the other way around, too?

In fact, yes, we can. Kind of. The result is linked under the title. I make use of the Greenlets module for this so you can't run it directly in standard CPython - you have to install the Greenlets. But they work with standard CPython 2.3 and are available for many platforms, so maybe you can give it a try.

I could even hack something like this with the normal threads and locks - it would be rather clumsy, but should be doable. But it would make the source more complicated, so for now I stay with Greenlets.

This post references topics: python
posted at 21:28:48    #
January 2005
MoTuWeThFrSaSu
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930
31      
Dec
2004
 Mar
2005

This is the Python Desktop Server weblog.


(Donations will be used by the author to buy stuff, fullfill selfish wishes or do other silly recreational things. You have been warned.).
The PyDS is
OSI Certified Open Source Software

Python Powered

XML-Image

© 2005-2007, Georg Bauer