Does Python optimize tail recursion?

后端 未结 6 1110
情深已故
情深已故 2020-11-22 02:30

I have the following piece of code which fails with the following error:

RuntimeError: maximum recursion depth exceeded

I attemp

6条回答
  •  余生分开走
    2020-11-22 03:16

    Besides optimizing tail recursion, you can set the recursion depth manually by:

    import sys
    sys.setrecursionlimit(5500000)
    print("recursion limit:%d " % (sys.getrecursionlimit()))
    

提交回复
热议问题