[Tutor] Stackless Python vs pyco vs OS?
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Sun, 22 Sep 2002 20:05:13 -0700 (PDT)
On Sun, 22 Sep 2002, Anthony Barker wrote:
> I still don't 100% understand stackless python
>
> OK it doesn't use the C stack It is faster for doing recursion and a bit
> faster overall
>
> Why else would someone use it?
Hmmm... you may actually want to ask this on comp.lang.python. Many of us
here on Tutor haven't followed this extension to the Python language, so
we may not be the best people to ask about the advantages of Stackless.
My understanding is that the main purpose of Stackless is to give
programmers the ability to fiddle around with "continutations", to hold
the scales of life and death over program flow.
Cameron Laird has organized lots of notes about Stackless, and most of
them concentrate on applying continuations to great effect:
http://phaseit.net/claird/comp.lang.python/stackless.html
Continuations allow one to write one's own control structures. For
example, Tismer originally implemented generators using continuations.
Not only generators, but other things like coroutines and microthreads.
So coroutines are extraordinarily powerful, if weird. *grin* I think the
other advantages of Stackless (speed, infinite recursion, not using C
stack) are just icing on the cake.
> Wouldn't this be better in the OS level? The 2.5x linux kernel contains
> support for both those things.
There's one counterpoint: Python does run on more than Linux. And another
of the big things about Stackless is that it should allow Python to get
around the stack limitations on the Palm platform.
> What about psyco - wouldn't that have much of the same effect?
Psyco, the specializing compiler, is entirely different: it aims to apply
JIT-like compilation of Python into machine code, so it's definitely aimed
for optimization. If you'd like to learn more about psyco, you can take a
look at:
http://psyco.sourceforge.net/
Good luck to you!