The StatePickler uses the hash function hash to generate a key for its object cache, at least for hashable objects. Without an extra equality check, this is broken, and leads to different objects with the same hash being treated as the same object.
Example failure resulting from this:
>>> from apptools.persistence.state_pickler import *
>>> loads_state(dumps([(-1, -1), (-2, -2), (-3, -3)]))
[(-1, -1), (-1, -1), (-3, -3)]
Here the error occurs because the tuples (-1, -1) and (-2, -2) have the same hash.
The
StatePickleruses the hash functionhashto generate a key for its object cache, at least for hashable objects. Without an extra equality check, this is broken, and leads to different objects with the same hash being treated as the same object.Example failure resulting from this:
Here the error occurs because the tuples
(-1, -1)and(-2, -2)have the same hash.