[Python-Dev] Proper tail recursion

Guido van Rossum guido at python.org
Thu Jul 15 03:36:16 CEST 2004


> JanC recommended I post this on python-dev to get feedback.  To sum up the 
> previous posts in my thread on comp.lang.python, I've created a patch that 
> optimizes tail calls in the CPython interpreter, so that the stack is not 
> used for functions called in a tail context.

I'm not interested in adding this to the official Python release.

One reason is that if an exception happens in such a tail-recursive
call, the stack trace will be confusing.

Another reason is that I don't think it's a good idea to try to
encourage a Scheme-ish "solve everything with recursion" programming
style in Python.

But feel free to maintain this as an independent modification, a la
Stackless -- I'm sure there are people who would like to try this
out.

--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list