This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients rhettinger, serhiy.storchaka
Date 2017-01-09.17:28:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483982931.8.0.297866865477.issue29216@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2017-01-09 17:28:51serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger
2017-01-09 17:28:51serhiy.storchakasetmessageid: <1483982931.8.0.297866865477.issue29216@psf.upfronthosting.co.za>
2017-01-09 17:28:51serhiy.storchakalinkissue29216 messages
2017-01-09 17:28:51serhiy.storchakacreate