Recursively traverse linked list -- help!

Jason Orendorff jason at jorendorff.com
Thu Feb 21 13:56:03 EST 2002


Terry Reedy wrote (to Paul Rubin):
> So, are you suggesting
> 
> A. general tail call optimization?
> 
>   If so, 'jump to' is problematic, since there is no frame object to
> jump to, the avoidance of creating such being part of the purpose of
> the optimization.  If the call is not recursive, I could imagine
> replacing the contents of the current frame.

That is not feasible, generally.

Here is how it might work.  Python could create a new frame.
The optimization is that the frame performing the tail call can be
culled right away, saving some memory and shortening the stack.
The culled frame would disappear from traceback information too,
unfortunately.

I'm sure this has been discussed endlessly before.

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list