Steven D'Aprano writes:
> I don't understand why my recursive function hits the recursion
> limit inside the timeit.Timer when it works outside of it.
Probably because your test function is at the very edge of the
recursion limit, and timeit.Timer triggers it because it calls it at a
deeper stac
namekuseijin schrieb:
Recursion is unpythonic. Do not use it.
Since when? Says who?
Lacking tail-recursion, it's not the choice for loops, but whatever
algorithm is recursive can be written as such.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, May 3, 2009 at 11:27 PM, namekuseijin
wrote:
> Recursion is unpythonic. Do not use it.
That's a tad extreme. I think the accepted practice is merely not to
use recursion gratuitously.
Cheers,
Chris
--
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list
Recursion is unpythonic. Do not use it.
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano schrieb:
I'm seeing a strange interaction between timeit and recursion.
sys.getrecursionlimit()
1000
from timeit import Timer
setup = """def test(n=1):
... if n < 999: return test(n+1)
... return None
... """
exec setup
I'm seeing a strange interaction between timeit and recursion.
>>> sys.getrecursionlimit()
1000
>>> from timeit import Timer
>>> setup = """def test(n=1):
... if n < 999: return test(n+1)
... return None
... """
>>>