[Python-Dev] Re: Proper tail recursion

Phillip J. Eby pje at telecommunity.com
Fri Jul 16 20:03:25 CEST 2004


At 10:45 AM 7/16/04 -0700, Josiah Carlson wrote:
>IMO it shouldn't be only about tail-call optimizations.  Andrew Koenig
>suggested that frames be allocated from the heap, which if it is
>possible (is there anything that gets executed directly by the processor
>so we have to worry about processors supporting NX?), seems to remove
>the C stack limit.

Frames *are* allocated on the heap.  That's not the problem.  The problem 
is that the interpreter *has* to use the C stack to call C functions, and 
Python objects are implemented using C functions.  Therefore, invoking 
operations on Python objects uses the C stack, in the general case.

(Which is why some versions of Stackless made extensive modifications to 
the Python core, in order to maximize the number of specific cases where C 
function calls could be avoided.)



More information about the Python-Dev mailing list