[Tutor] Re: rre: Recursion error
Andrei
project5 at redrival.net
Wed Oct 1 01:43:54 EDT 2003
Kirk Bailey wrote:
> Well, I tried this:
>
> def test(count):
> print count
> count=count+1
> test(count)
Tried that only I do the count increase inside the function call.
> and when the count got to 346, I chickened out and hit ^C, and got a
Got up to 984, nothing interesting happens:
983
984
Traceback (most recent call last):
File "<input>", line 1, in ?
File "<input>", line 3, in test
I don't have to wait at all, the traceback appears virtually instantaneously. I
couldn't even stop it at 300 if I wanted to :). But that's in wxPython, perhaps
Tk is slower and that's why you didn't get that far. The limit seems to be
pretty much fixed, memory use is negligeable.
> HUGE error report back. I will spare the list. But it went WELL past 50
> recursions. Of course, this was a small and simple function, and did not
> tax the stack at all heavily per recursion.
Tried more memory consuming test too:
>>> class X(object):
... def __init__(self, i):
... self.list = [10,10,10,10,10,10,10,10,10,10]*i
...
>>> def test(i):
... l.append(X(i))
... print i
... test(i+1)
...
>>> l = []
>>> test(0)
<snip output and traceback>
>>> len(l[-1].list)
9850
Stops at 984 too, but eats about 22MB of mem.
--
Yours,
Andrei
=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur
yvfg, fb gurer'f ab arrq gb PP.
More information about the Tutor
mailing list