Posted on 2022-09-25 11:15
Tail-call optimisation in Python using ast
Python does not have tail-call optimisation (TCO), and it likely never will.
Several packages exist that add TCO via decorators (e.g., tco
).
Most of these packages use some lambda calculus to implement TCO.
In this post I want to explore an alternative way to achieve TCO, using the ast
module to rewrite the decorated function.
Read more