Q
Does CPython optimize tail-recursive calls (tail-call optimization)?
-
A
Only in Python 3.11 and later
-
B
No; tail calls still consume stack frames
-
C
Yes, always
-
D
Yes, when @tailrec is used
Correct Answer:
B. No; tail calls still consume stack frames
Explanation:
Python intentionally omits TCO to keep tracebacks complete. Scala has @tailrec; Python does not.