def __hash__(self):
    return self._hash
p = PhonyHash()
d = {p: 'val'}
print(p in d)
p._hash = 2
print(p in d)
p._hash = 9
print(p in d)
Class with changing __hash__ still works with dictionary access