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

前端 未结 17 2927
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 04:14

I have this tail recursive function here:

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


        
17条回答
  •  野性不改
    2020-11-21 05:06

    Looks like you just need to set a higher recursion depth:

    import sys
    sys.setrecursionlimit(1500)
    

提交回复
热议问题