> Just to be more pedantic: it did use tail calls, but the recursive calls weren't the tail calls.
I was talking about this code:
def fib(n):
if n =< 0:
return (0, 1)
else:
a, b = f(n-1)
return (b, a + b)
Not sure what you mean by tail calls here. I don't see Python-level tail calls. The interpreter will call C code for tuple packing, but those aren't in tail position with respect to the Python code either.
Because after tuple packing returns (a C return) you still need to perform a Python return. The C tuple packing function cannot return directly from the Python function.
I was talking about this code:
Not sure what you mean by tail calls here. I don't see Python-level tail calls. The interpreter will call C code for tuple packing, but those aren't in tail position with respect to the Python code either.