Tail recursion to while iteration in 2 easy steps
Mark Janssen
dreamingforward at gmail.com
Wed Oct 2 14:59:49 EDT 2013
>> def fact(n): return 1 if n <= 1 else n * fact(n-1)
>>
>> into a tail recursion like
> [...]
>
> How do know that either "<=" or "*" didn't rebind the name "fact" to
> something else? I think that's the main reason why python cannot apply
> any procedural optimization (even things like inlining are impossible,
> or possible only under very conservative assumption, that make it
> worthless).
It's called "operator precedence".
--
MarkJ
Tacoma, Washington
More information about the Python-list
mailing list