Possibly Pythonic Tail Call Optimization (TCO/TRE)

Marko Rauhamaa marko at pacujo.net
Wed Jul 15 10:55:26 EDT 2015


Ian Kelly <ian.g.kelly at gmail.com>:

> On Tue, Jul 14, 2015 at 11:27 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> You'll see that the generated code is tail-call-optimized.
>
> This can't be done generally, though. What if, instead of a local
> variable, the assignment were to a dict item? Even if the dict itself
> is a local variable, the assignment can't be optimized away.

Of course, you can only do correct optimizations. My point is that tail
call optimizations should not be micromanaged by the programmer.


Marko



More information about the Python-list mailing list