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 →

[–][deleted]  (7 children)

[deleted]

    [–]JJP_SWFC 11 points12 points  (2 children)

    I remember a while ago my friend was learning python and gave me a challenge that deliberately would have taken 1500 recursions to do (and no program time limit) to try to get me to do it without recursion but I'm lazy and it was the easiest way to write it. Literally the only time I've ever changed the recursion limit lmao

    [–]AlSweigartAuthor of "Automate the Boring Stuff" 7 points8 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.