Python's "only one way to do it" philosophy isn't good?

Josiah Carlson josiah.carlson at sbcglobal.net
Sat Jun 9 16:05:05 EDT 2007


James Stroud wrote:
> Terry Reedy wrote:
>> In Python, you have a choice of recursion (normal or tail)
> 
> Please explain this. I remember reading on this newsgroup that an 
> advantage of ruby (wrt python) is that ruby has tail recursion, implying 
> that python does not. Does python have fully optimized tail recursion as 
> described in the tail recursion Wikipedia entry? Under what 
> circumstances can one count on the python interpreter recognizing the 
> possibility for optimized tail recursion?

Note that Terry said that you could do normal or tail recursion, he 
didn't claim that either were optimized.  As for why tail calls are not 
optimized out, it was decided that being able to have the stack traces 
(with variable information, etc.) was more useful than offering tail 
call optimization (do what I say).

  - Josiah



More information about the Python-list mailing list