I'm playing around with lru_cache in python and struggling to get it to work >.o does anyone know what I'm doing wrong>?
from functools import lru_cache
class Foo(object):
def __init__(self, a):
self.a = a
def __hash__(self) -> int:
return hash(self.a)
@lru_cache(maxsize=None)
def test(a: Foo):
print('hi')
return None
if __name__ == '__main__':
f1 = Foo(1)
f2 = Foo(1)
# should print 'hi'
test(f1)
# should NOT print 'hi', but does print 'hi'
test(f2)