[Python-ideas] Tail recursion elimination
Stefan Behnel
stefan_ml at behnel.de
Sun Jan 19 12:24:51 CET 2014
Andrew Barnert, 18.01.2014 19:29:
> The first problem is that CPython makes a C function call for every
> Python function call, and C doesn't eliminate tail calls; the only way
> to do it manually is with longjmp
Many C compilers actually fold tail recursion into loops. However, that has
nothing to do with an *interpreter* that happens to be written in C not
eliminating tail recursion. There is no technical reason you couldn't do
TRE in CPython at the *interpreter* level. And this has nothing to do with
longjmp.
Stefan
More information about the Python-ideas
mailing list