Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
--------- Demonstration of one of the bugs --------- # The currsize is initially equal to maxsize of 10 # Then we cause an orphan link in a full cache # The currsize drops to 9 and never recovers the full size of 10 from functools import lru_cache once = True @lru_cache(maxsize=10) def f(x): global once rv = f'.{x}.' if x == 20 and once: once = False print('Calling again', f(x)) return rv for x in range(15): f(x) print(f.cache_info()) print(f(20)) print(f.cache_info()) print(f(21)) print(f.cache_info()) ------ Output -------- CacheInfo(hits=0, misses=15, maxsize=10, currsize=10) Calling again .20. .20. CacheInfo(hits=0, misses=17, maxsize=10, currsize=9) .21. CacheInfo(hits=0, misses=18, maxsize=10, currsize=9) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35780> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com