Possibly Pythonic Tail Call Optimization (TCO/TRE)
Mark Lawrence
breamoreboy at yahoo.co.uk
Tue Jul 14 19:40:14 EDT 2015
On 13/07/2015 23:46, Terry Reedy wrote:
>
> Optimizing specific tail calls is tricker. For one thing, calls to a
> recursion-replacement function, such as recur, add a stack frame that
> must also be popped. A CPython bytecode manimpuation solution was given
> years ago as a recipe on the ActiveState Python Cookbook site. MacroPy
> at pypi.python.org "provides a mechanism for user-defined functions
> (macros) to perform transformations on the abstract syntax tree(AST) of
> Python code at module import time". Among many included examples, it
> has a tco decorator.
>
A direct link https://github.com/lihaoyi/macropy#tail-call-optimization
for anybody who is interested.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list