Reuven M. Lerner @lernerpython.com · 7d

Old #Python: a hand-rolled _cache = {} with an "if n not in _cache" check. New Python: @cache def slow(n): ... functools.cache (3.9) memoizes a function's return values automatically — no cache dictionary to write. Faster and smaller than lru_cache.

2 likes 0 replies

?