[issue11011] More functools functions

Nick Coghlan report at bugs.python.org
Wed Jan 26 12:58:40 CET 2011


Nick Coghlan <ncoghlan at gmail.com> added the comment:

How the conversion from a recursive algorithm to an iterative one works depends on the specific algorithm involved. A trampoline does the job for tail calls, but not necessarily any other recursive algorithm.

Factorial actually has a fairly trivial iterative algorithm, so it isn't a great example for general purpose algorithm conversion:

def factorial(x):
  result = 1
  for i in range(1, x+1):
    result *= i
  return result

I believe having trampoline in functools would end up being something of an attractive nuisance - in cases where it applies, there are probably better, algorithm specific, ways of eliminating a recursive call.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11011>
_______________________________________


More information about the Python-bugs-list mailing list