On 14 Dec 2006 at 7:48, Armin Rigo wrote: > Hi Lenard, > > On Wed, Dec 13, 2006 at 03:50:21PM -0800, Lenard Lindstrom wrote: > > Tasklets are nice, but I just wish to update my understanding of > > "Stackless". Does the old motto "A Python Implementation That Does > > Not Use The C Stack" [1] still apply? Is it relevant to PyPy? > > Yes and no. A bit confusingly, the usage of the term has evolved, along > with the Stackless Python project itself. Now, "a Stackless feature" > means a feature that cannot be implemented without some form of explicit > stack control, either by being very careful about the C code (e.g. > avoiding recursive calls) or by saving and restoring pieces of the C > stack by a brute force 'memcpy' approach. In PyPy, we use a variant of > the former approach: a "stackless build" of pypy-c is a compiled version > of some C code that was generated with careful systematic tweaks. > > The motto of a Stackless PyPy is probably: "A Python implementation that > uses the C Stack as a cache". Indeed, the C code supports saving its > own stack of frames away into the heap, and restoring it from there, > frame by frame. So the C stack is really just a cache for the heap. If > the cache is full (stack overflow), we save some more frames into the > heap to free some cache space. If a context switch occurs (coroutine > switch) the cache is invalidated (entierely flushed to the heap) and the > new context's frames are copied from the heap to the cache as needed > (the function's frames are resumed one by one). > Hi Armin,
Thanks for the explanation. I find that "Stackless" is still associated with Scheme like continuations and unlimited recursion [1]. But yes, the PyPy documentation clearly states that "Stackless" means greenlets, coroutines and tasklets at the application level. [1] http://en.wikipedia.org/wiki/Stackless Lenard Lindstrom <[EMAIL PROTECTED]> _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
