You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for the slightly wrong info - the problem also persisted in Python 3.12 on Windows (I was not running the program with Python 3.12 on my Windows machine). I just downloaded the Windows binaries for Python 3.10.10, 3.11.7, and 3.12.7, and all have problems with increasing the recursionlimit and the functools.cache.
I know increasing the recursion limit comes with a risk, so I ask for trouble. I was just hopping that I always could use functools.cache instead of writing my own @cache decorator, like the below. The below @cache decorator handles significantly higher recursion depths with Python 3.13.0 on Windows (and with 3.12 and 3.11, but not with 3.10).
import sys
sys.setrecursionlimit(1_000_000)
def cache(f):
answers = {}
def wrapper(x):
if x not in answers:
answers[x] = f(x)
return answers[x]
return wrapper
@cache
def double(n):
return 2 + double(n - 1) if n > 0 else 0
print(f'{double(400_000) = }') # prints 800_000
Sorry for the slightly wrong info - the problem also persisted in Python 3.12 on Windows (I was not running the program with Python 3.12 on my Windows machine). I just downloaded the Windows binaries for Python 3.10.10, 3.11.7, and 3.12.7, and all have problems with increasing the recursionlimit and the functools.cache.
I know increasing the recursion limit comes with a risk, so I ask for trouble. I was just hopping that I always could use functools.cache instead of writing my own @cache decorator, like the below. The below @cache decorator handles significantly higher recursion depths with Python 3.13.0 on Windows (and with 3.12 and 3.11, but not with 3.10).
import sys
sys.setrecursionlimit(1_000_000)
def cache(f):
answers = {}
def wrapper(x):
if x not in answers:
answers[x] = f(x)
return answers[x]
return wrapper
@cache
def double(n):
return 2 + double(n - 1) if n > 0 else 0
print(f'{double(400_000) = }') # prints 800_000
Yeah, I understand your concerns, Gerth. Can you please continue discussion on #112215? Thanks in advance!
Activity
Eclips4 commentedon Nov 27, 2024
Duplicate of #112215
@functools.cache#112215gsbrodal commentedon Nov 27, 2024
Sorry for the slightly wrong info - the problem also persisted in Python 3.12 on Windows (I was not running the program with Python 3.12 on my Windows machine). I just downloaded the Windows binaries for Python 3.10.10, 3.11.7, and 3.12.7, and all have problems with increasing the recursionlimit and the
functools.cache.I know increasing the recursion limit comes with a risk, so I ask for trouble. I was just hopping that I always could use
functools.cacheinstead of writing my own@cachedecorator, like the below. The below@cachedecorator handles significantly higher recursion depths with Python 3.13.0 on Windows (and with 3.12 and 3.11, but not with 3.10).Eclips4 commentedon Nov 28, 2024
Yeah, I understand your concerns, Gerth. Can you please continue discussion on #112215? Thanks in advance!