Tail recursion to while iteration in 2 easy steps

random832 at fastmail.us random832 at fastmail.us
Wed Oct 2 08:31:25 EDT 2013


On Tue, Oct 1, 2013, at 17:30, Terry Reedy wrote:
> Part of the reason that Python does not do tail call optimization is 
> that turning tail recursion into while iteration is almost trivial, once 
> you know the secret of the two easy steps. Here it is.

That should be a reason it _does_ do it - saying people should rewrite
their functions with loops means declaring that Python is not really a
multi-paradigm programming language but rather rejects functional
programming styles in favor of imperative ones.



More information about the Python-list mailing list