I am testing the recursion limit with
In [19]: ??foo
Signature: foo()
Docstring: <no docstring>
Source:
def foo():
global count
count += 1
print(count)
return foo()
File: ~/<ipython-input-6-9b0629ed4ce8>
Type: function
Then run
count = 0; foo()
and got the error:
2979
2980
2981
---------------------------------------------------------------------------
RecursionError Traceback (most recent call last)
<ipython-input-20-7b6881a8dc94> in <module>
----> 1 count = 0; foo()
<ipython-input-6-9b0629ed4ce8> in foo()
3 count += 1
4 print(count)
----> 5 return foo()
6
7
... last 1 frames repeated, from the frame below ...
<ipython-input-6-9b0629ed4ce8> in foo()
3 count += 1
4 print(count)
----> 5 return foo()
6
7
RecursionError: maximum recursion depth exceeded while calling a Python object
the recursion limit is
In [22]: sys.getrecursionlimit()
Out[22]: 3000
Since the recursion limit is 3000, why it always stops at 2981?