Possibly Pythonic Tail Call Optimization (TCO/TRE)

Chris Angelico rosuav at gmail.com
Tue Jul 14 07:33:55 EDT 2015


On Tue, Jul 14, 2015 at 3:41 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Tail-call optimization has nothing to do with converting algorithms into
> iterations. It's a prosaic trick of dropping an unneeded stack frame
> before making a function call.
>
>> The claim that TCO means you don't need stack space for all those
>> levels of recursion doesn't work if you still need stack space for all
>> those levels of recursion *before* you get to the tail call.
>
> Nobody is making that claim.

Actually, that claim was made - that Python's stack would overflow if
you didn't optimize tail calls away. I don't feel like digging up
through the history to find out who first made the claim, but it was
made in this thread.

ChrisA



More information about the Python-list mailing list