Steve Howell wrote: > --- "Anders J. Munch" <[EMAIL PROTECTED]> wrote: > >>Converting tail-recursion to iteration is trivial, >>and perfectly reasonable for >>a human to do by hand. You add an outer "while >>True"-loop, the recursive call >>becomes a tuple assignment, and other code paths end >>with a break out of the >>loop. Completely mechanical and the resulting code >>doesn't even look that bad. >> > > > I have to ask the stupid question. If a human can do > this completely mechanically, why can't a machine?
That's what tail recursion optimization is. It's not a high-priority optimization for CPython. The language has good iteration primitives, so iterating via simple recursion is relatively rare and not, typically, a performance bottleneck. In LISP, one might iterate over a list using tail recursion, but in Python, that would be both silly and inefficient. John Nagle -- http://mail.python.org/mailman/listinfo/python-list