Message285058
Ah, there is a wart in the optimization in Python implementation. If call a cached function with multiple integer arguments and with equivalent float arguments, the second call will return a cached result. But if call with single integer and float arguments, both calls will be cached separately.
>>> import functools
>>> @functools.lru_cache()
... def f(*args):
... return args
...
>>> f(1, None)
(1, None)
>>> f(1.0, None)
(1, None)
>>> f.cache_info()
CacheInfo(hits=1, misses=1, maxsize=128, currsize=1)
>>> f.cache_clear()
>>> f(1)
(1,)
>>> f(1.0)
(1.0,)
>>> f.cache_info()
CacheInfo(hits=0, misses=2, maxsize=128, currsize=2) |
|
Date |
User |
Action |
Args |
2017-01-09 17:28:51 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger |
2017-01-09 17:28:51 | serhiy.storchaka | set | messageid: <1483982931.8.0.297866865477.issue29216@psf.upfronthosting.co.za> |
2017-01-09 17:28:51 | serhiy.storchaka | link | issue29216 messages |
2017-01-09 17:28:51 | serhiy.storchaka | create | |
|