Re: Strange interaction between timeit and recursion

2009-05-04 Thread Hrvoje Niksic
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

Re: Strange interaction between timeit and recursion

2009-05-03 Thread Diez B. Roggisch
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

Re: Strange interaction between timeit and recursion

2009-05-03 Thread Chris Rebert
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

Re: Strange interaction between timeit and recursion

2009-05-03 Thread namekuseijin
Recursion is unpythonic. Do not use it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange interaction between timeit and recursion

2009-05-03 Thread Diez B. Roggisch
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

Strange interaction between timeit and recursion

2009-05-03 Thread Steven D'Aprano
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 ... """ >>>