Possibly Pythonic Tail Call Optimization (TCO/TRE)

Antoon Pardon antoon.pardon at rece.vub.ac.be
Tue Jul 14 10:02:10 EDT 2015


On 07/14/2015 03:43 PM, Chris Angelico wrote:
> On Tue, Jul 14, 2015 at 11:38 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> Chris Angelico <rosuav at gmail.com>:
>>
>>> On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>>> I would rather optimize by default and disable optimizations with
>>>> --debug or equivalent.
>>> That assumes that it's simply an optimization. This is a distinct
>>> semantic change.
>> No, tail call optimization doesn't change the behavior of the program,
>> for the worse anyway.
> It does, because you lose traceback records. That's pretty significant
> when you come to try to debug something.

I doubt it would be really significant. Not compared to writing it iteratively.
When you write it iteratively, you don't get to keep a traceback record per time
you go throught the loop. So the traceback records you loose in tale call elimination
would be the traceback records you wouldn't have anyway in the iterative version.

So how would this be significant?




More information about the Python-list mailing list