Author serhiy.storchaka
Recipients rhettinger, serhiy.storchaka
Date 2017-01-09.17:28:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)
>>> f(1.0)
>>> f.cache_info()
CacheInfo(hits=0, misses=2, maxsize=128, currsize=2)
Date User Action Args
2017-01-09 17:28:51serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger
2017-01-09 17:28:51serhiy.storchakasetmessageid: <>
2017-01-09 17:28:51serhiy.storchakalinkissue29216 messages
2017-01-09 17:28:51serhiy.storchakacreate