[Python-Dev] Proper tail recursion

Christopher T King squirrel at WPI.EDU
Wed Jul 14 21:13:37 CEST 2004

On Wed, 14 Jul 2004, Michael Hudson wrote:

> I guess I could have said this in c.l.py, but: what's the point?  I
> don't think I've ever had a situation where hitting the recursion
> limit wasn't a bug, and given a) the ease with which a non-contrivedly
> tail recursive algorithm can usually be rewritten iteratively and b)
> the (lack of) speed of function calls in today's Python I can't see
> any huge real advantage to this patch.

To tell the truth, I don't really have any immediate use for this
functionality, either, but since it turned out to be so easy to implement,
I ask, "why not?" ;) Presuming it doesn't break any existing
functionality, of course.* I prefer to think of it in the same light as
the opcode prediction macros, i.e. as a performance enhancement, rather
than as an attempt to introduce a new paradigm to the language (which it

* I know it breaks stack traces, but the final implementation will only be 
used when the -O flag is specified, or some other such indicator is set.

More information about the Python-Dev mailing list