Re: Why no tailcall-optimization?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jean-Paul Calderone

    #1

    Re: Why no tailcall-optimization?

    On Tue, 23 Sep 2008 06:41:33 -0700 (PDT), sturlamolden <sturlamolden@y ahoo.nowrote:
    >On Sep 23, 3:13 am, process <circularf...@g mail.comwrote:
    >
    >Why doesn't Python optimize tailcalls? Are there plans for it?
    >
    >Because Python is a dynamic language. While a function is executing,
    >its name may be bound to another object. It may happen as a side
    >effect of what the function is doing, or even from another thread. The
    >compiler has no way of knowing that.
    That's not the reason. It's not particularly hard to implement TCE for
    Python. Instead, Guido has repeatedly given the reason as his feeling
    that recursion is not the most natural way to express most algorithms
    in Python. Adding TCE to the runtime would encourage people to write
    (or continue to write) highly recursive algorithms, which would go
    against what Guido thinks is "Pythonic". Here's a quote from him on
    the topic:
    But I have a problem with tail recursion. It's generally requested by
    new converts from the Scheme/Lisp or functional programming world, and
    it usually means they haven't figured out yet how to write code
    without using recursion for everything yet. IOW I'm doubtful on how
    much of a difference it would make for real Python programs (which,
    simplifying a bit, tend to use loops instead of recursion).
    Jean-Paul
Working...