This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Jason.Baker, eric.araujo, ncoghlan, rhettinger
Date 2011-01-26.11:58:39
SpamBayes Score 2.647825e-06
Marked as misclassified No
Message-id <>
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.
Date User Action Args
2011-01-26 11:58:40ncoghlansetrecipients: + ncoghlan, rhettinger, eric.araujo, Jason.Baker
2011-01-26 11:58:40ncoghlansetmessageid: <>
2011-01-26 11:58:40ncoghlanlinkissue11011 messages
2011-01-26 11:58:40ncoghlancreate