[Python-Dev] Proper tail recursion

"Martin v. Löwis" martin at v.loewis.de
Thu Jul 15 21:08:24 CEST 2004

Michael Chermside wrote:
> No... that answer applies to *language features*, but not *implementation
> details*. The recursion limit (the value of it anyhow) is an
> implementation detail.

No, it is not. In standard Python, the program

def rec(n):

while 1:
   except RuntimeError:
print "The recursion limit is", n

will terminate. In the modified Python, it will not terminate.
It is a change in behaviour, and thus a language feature.

> This doesn't bother me as much as it apparently bothers you. But for
> that matter, we hardly care about performance if we're going to be
> generating a stack trace, so we could probably construct the stack
> trace after-the-fact if needed.

No, you can't: You forgot already what all the local variables where.


More information about the Python-Dev mailing list