Message400209
This seems like unexpected behavior: Two keys that are equal and have equal hashes should yield cache hits, but they do not.
Python 3.9.6 (default, Aug 18 2021, 19:38:01)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
>>>
>>> import numpy as np
>>>
>>> @functools.lru_cache(maxsize=None)
... def f(x):
... return x
...
>>> py_str = 'hello world'
>>> np_str = np.str_(py_str)
>>>
>>> assert py_str == np_str
>>> assert hash(py_str) == hash(np_str)
>>>
>>> assert f.cache_info().currsize == 0
>>> f(py_str)
'hello world'
>>> assert f.cache_info().currsize == 1
>>> f(np_str)
'hello world'
>>> assert f.cache_info().currsize == 2
>>> print(f.cache_info())
CacheInfo(hits=0, misses=2, maxsize=None, currsize=2) |
|
Date |
User |
Action |
Args |
2021-08-24 13:36:59 | brilee | set | recipients:
+ brilee |
2021-08-24 13:36:59 | brilee | set | messageid: <1629812219.83.0.183087595287.issue44992@roundup.psfhosted.org> |
2021-08-24 13:36:59 | brilee | link | issue44992 messages |
2021-08-24 13:36:59 | brilee | create | |
|