[Python-Dev] Proper tail recursion
Michael Hudson
mwh at python.net
Wed Jul 14 20:45:01 CEST 2004
Christopher T King <squirrel at WPI.EDU> writes:
> 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 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.
It's a cute hack though :-)
Cheers,
mwh
--
if-you-need-your-own-xxx.py-you-know-where-to-shove-it<wink>-ly
y'rs - tim
-- Tim Peters dishes out versioning advice on python-dev
More information about the Python-Dev
mailing list