I've made a small function that will actually measure the max recursion limit:
def f(x):
r = x
try:
r = f(x+1)
except Exception as e:
print(e)
finally:
return r
To know what to expect I've checked:
In [28]: import sys
In [29]: sys.getrecursionlimit()
Out[29]: 1000
However
In [30]: f(0)
maximum recursion depth exceeded
Out[30]: 970
The number is not fixed, always around ~970, and slightly changes between different instances of python (e.g. from within spyder to system cmd prompt).
Please note that I'm using ipython on python3.
What's going on? Why is the actual limit I'm getting lower than the sys.getrecursionlimit()
value?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…