On Wed, 16 Apr 2008 13:18:22 -0700 (PDT), [EMAIL PROTECTED] wrote: >the 0.409 vs 0.095 is the total times right? >so the imperative function is >4 times faster than the recursive. >or what does tottime stand for? > >is this always the case that the recursive function is slower? >the gain is less code? > >are some functions only implementable recursively? >
Function calls (recursive or otherwise) are more expensive than for loops, so the version that replaces recursion with a loop is faster. Any function can be implemented without recursion, although it isn't always easy or fun. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list