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

前端 未结 17 2922
佛祖请我去吃肉
佛祖请我去吃肉 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 04:59

    Use a language that guarantees tail-call optimisation. Or use iteration. Alternatively, get cute with decorators.

提交回复
热议问题