Message334051
--------- 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) |
|
Date |
User |
Action |
Args |
2019-01-19 09:31:08 | rhettinger | set | recipients:
+ rhettinger, serhiy.storchaka |
2019-01-19 09:31:07 | rhettinger | set | messageid: <1547890267.07.0.0655530638913.issue35780@roundup.psfhosted.org> |
2019-01-19 09:31:07 | rhettinger | link | issue35780 messages |
2019-01-19 09:31:07 | rhettinger | create | |
|