[Stackless] Wow

Christian Tismer tismer at tismer.com
Fri Dec 19 11:31:23 CET 2003


Fred Frick wrote:

> I saw your post about stackless being able to pickle generators, that is 
> the coolest thing ever. With this new capability a whole range of new  
> programming options has been made available. My company is building a 
> game that prior to this had scrapped a perfectly elegant way of 
> simulating NPCs by using generators as light weight threads becuase of 
> the pickling problem. Thanks to you our preferred implementation can now 
> be realized.

Nice to hear that.
Depending on your layout, it might be even nicer to use
tasklets instead of generators. Generators are slightly
more efficient, tasklets are more versatile. It depends.

Currently, generators can be pickled and unpickled
when they are inactive. When they are activated, they
behave like in original Python, and pickling them
will create a non-runnable pickle, because a C stack
is involved.
This problem will vanish, soon, I'm going to write
a non-recursive generator version which can be pickled
even while beign executed.

> My question is whether or not this extension is specific
 > to stackless and if not do you have any plans on
> porting stackless to 2.3 or submitting the generator modifications for 
> inclusion in the normal python distribution as we already have 
> numerous 2.3 dependencies.

1) I am working on a port to Python 2.3, but I don't have
    enough time and need some financial support.
    If a company can help, it will be done in 2-3 weeks.
    It is a lot of work.

2) Implementing generator pickling the way it is now was
    a cake walk, it took me three hours inclusive debugging.
    This is due to the fact that Stackless already has
    the ability to pickle
    - frames,
    - code objects
    - iterators (both kinds)
    - tracebacks
    - modules
    and some more.
    This whole machinery would be needed to be ported to
    standard Python.

3) As it stands, I think it would be possible to do a port
    to Standard Python, if the pickling takes place only
    when the generator is inactive (not executed).
    I don't plan yet to do this, since all that effort just
    for pickling generators didn't sound worth it.
    For me, this is a side product. The real strength is
    pickling tasklets, full execution threads.
    For example, see the following Zope application:
    http://www.centera.de/tismer/stackless/zope_demo/

thanks for using Stackless -- chris
-- 
Christian Tismer             :^)   <mailto:tismer at tismer.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/

_______________________________________________
Stackless mailing list
Stackless at www.tismer.com
http://www.tismer.com/mailman/listinfo/stackless




More information about the Stackless mailing list