Possibly Pythonic Tail Call Optimization (TCO/TRE)

Chris Angelico rosuav at gmail.com
Tue Jul 14 08:55:48 EDT 2015


On Tue, Jul 14, 2015 at 10:28 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> Done explicitly like this, it avoids the problem of bad tracebacks,
>> because by definition you would use it only when you want the current
>> stack frame to be dropped. I wonder how hard it would be to hack this
>> into CPython... Anyone feel like tackling it?
>
> 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. Would you, for instance, want all of your arithmetic
to be rounded to integer because integers are faster - and then
disable this "optimization" with a flag that permits floating-point
arithmetic? Certainly not.

ChrisA



More information about the Python-list mailing list