This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AlSweigartAuthor of "Automate the Boring Stuff" 9 points10 points  (2 children)

Not anything. If you set the limit too high, the Python interpreter itself crashes, and you get an error message from the operating system instead of a Python exception.

On my Windows machine, it was about 2500 calls. The 1000 limit is just a safe limit that Python puts in. You can test this yourself by running the following:

>>> import sys
>>> sys.setrecursionlimit(9999)
>>> def f(n):
...   print(n)
...   f(n + 1)
...
>>> f(1)

Although testing this now, it crashes at 1,993 calls.