[Python] What is the maximum recursion depth, and how to increase it?

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    I have this tail recursive function here:

    def recursive_function(n, sum):
    if n < 1:
    return sum
    else:
    return recursive_function(n-1, sum+n)

    c = 998
    print(recursive_function(c, 0))


    It works up to n=997, then it just breaks and spits out a RecursionError: maximum recursion depth exceeded in comparison. Is this just a stack overflow? Is there a way to get around it?

    Continue reading...

Compartilhe esta Página