Код: Выделить всё
sys.setrecursionlimit
Код: Выделить всё
from functools import cache
import sys
sys.setrecursionlimit(3000)
@cache
def f1(n):
if n == 1: return 1
return n * f1(n-1)
mycache = {}
def f2(n):
if n in mycache:
return mycache[n]
if n == 1: val = 1
else: val = n * f2(n-1)
mycache[n] = val
return val
f2(2000) # this works
f1(2000) # this fails at a depth of 500 with the error:
# "RecursionError: maximum recursion depth exceeded while calling a Python object"
< р>Что здесь происходит и есть ли способ изменить предел рекурсии для функций, объявленных с помощью @class?
Подробнее здесь: https://stackoverflow.com/questions/789 ... ools-cache