[Python-Dev] Stackless Python

Christian Tismer tismer at stackless.com
Wed Jun 2 13:35:05 EDT 2004


Martin v. Löwis wrote:
> Bob Ippolito wrote:
> 
>>> However, JCSP uses java.lang.Threads to implement concurrency. So they
>>> are completely unlike Stackless' tasklets in their implementation
>>> strategy.
>>
>>
>>
>> So what, if the API is the same?
> 
> 
> If you don't have a problem with that, I don't either.
> 
>> Using the stack or not is an implementation detail, what matters is 
>> having more control over the flow of your programs in a reasonably 
>> efficient manner.  It just so happens that the recursive evaluation in 
>> CPython uses the stack in such a way that makes these kind of 
>> constructs impossible, so it needed to be changed for Stackless.
> 
> 
> That is simply not true. It is possible and straight-forward to
> implement Stackless' tasklets and channels on top of the standard
> Python, with no need to change the interpreter proper.

This is true, we have written demo implementations of tasklets
with pure Python and threads on the last sprint.

The difference is that nobody would use these for production code,
when tasklets are used frequently, because real threads are at
least an order of magnitude slower than tasklet switching.
This high speed of context switch is what makes certain kinds of
algorithms even useful. You will do things with tasklets which
you never would seriously do with threads, because a context switch
is as cheap as a builtin function call.

This makes the big difference.

The compatibility issue (same API etc.) just guarantees that
such code would run on regular Python and Jython as well.
It would be very slow, no doubt, but it would just work.

Still, tasklets make sense in the first place if they are fast.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/




More information about the Python-Dev mailing list