0

Does Python have optimized tail recursion?

Tail recursion is a form of recursion where the recursive call is the last action a function performs and its result is also the function's return value. This means the function does not have to keep track of internal state during the recursion, allowing it to recurse using a constant amount if memory - as opposed to unoptimized recursion, which requires a little bit of memory for each recursive call. Does Python have this optimization?

3rd Feb 2017, 4:52 AM
Phipps
1 Answer
+ 1
Nope. Furthermore, GvR himself is an enemy of it, as it is "unpythonic" and can lead to some programmers writing code that depends on it, while some language implementations might not include it.
5th Feb 2017, 6:41 PM
DotJason