C callbacks ? Re: Is Stackless Python DEAD?

Christian Tismer tismer at tismer.com
Tue Jan 15 13:59:34 EST 2002


Frederic Giacometti wrote:

> "Gordon McMillan" <gmcm at hypernet.com> wrote in message
> news:Xns91515922BE028gmcmhypernetcom at 199.171.54.214...
> 
>>John S. Yates, Jr. wrote:
>>
>>
>>>On 5 Nov 2001 13:53:28 GMT, amk at localhost.debian.org (A.M. Kuchling)
>>>wrote:
>>>
>>But making Python *truly* stackless means getting rid of all recursions,
>>and that is an enormous task. If you don't do that, you've got a
>>language feature that doesn't work in some apparently random
>>set of circumstances.
>>
> 
> But how do you process callbacks to Python from C code (extensions or
> embeded python)?


Either you do it as before. Then you get the known behavior
of Python. You cannot restart uthreads from your C extension
nested Python code, unless it starts its own scheduling and
terminates this until returning to the C code.

Or: You rewrite your C extension in a way that it vanishes from
the C stack while it is executing Python code. This is not
trivial. A good example is stackless' map, which does eactly this.


> One has to return to C after executing the Python code, and than C has to
> return to Python after executing the remainer of its code...


Exactly. The C code has to put all its state info into a frame
and play the frame chain game, as Python functions do. If it
adheres to that rule, everything works seamlessly.
In a way, your C code becomes "the interpreter" for this frame.
A frame structure with better support for this has to be
developed. Currently, there are just a few extra fields which
I used for my specific stuff, like stackless map and full
continuation support.
In the long term, I wish to have more general frames which can
be adjusted to the extension's needs.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net/
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
      where do you want to jump today?   http://www.stackless.com/






More information about the Python-list mailing list