pythonpython-stackless

What would I use Stackless Python for?


There are many questions related to Stackless Python. But none answering this my question, I think (correct me if wrong - please!). There's some buzz about it all the time so I curious to know. What would I use Stackless for? How is it better than CPython?

Yes it has green threads (stackless) that allow quickly create many lightweight threads as long as no operations are blocking (something like Ruby's threads?). What is this great for? What other features it has I want to use over CPython?


Solution

  • It allows you to work with massive amounts of concurrency. Nobody sane would create one hundred thousand system threads, but you can do this using stackless.

    This article tests doing just that, creating one hundred thousand tasklets in both Python and Google Go (a new programming language): http://dalkescientific.com/writings/diary/archive/2009/11/15/100000_tasklets.html

    Surprisingly, even if Google Go is compiled to native code, and they tout their co-routines implementation, Python still wins.

    Stackless would be good for implementing a map/reduce algorithm, where you can have a very large number of reducers depending on your input data.