[Twisted-Python] Why must RemoteCacheObservers be hashable?
![](https://secure.gravatar.com/avatar/e93e18f71a5821a54c233690506bdbf7.jpg?s=120&d=mm&r=g)
Nov. 27, 2013
10:34 a.m.
I just wrote up a class that allows dicts to be be pb.Cacheable. Everything works hunky-dory but only if I implement __hash__, which is problematic for mutable objects for reasons explained thoroughly elsewhere. The problem comes from twisted.spread.flavors.RemoteCacheObserver: class RemoteCacheObserver: ... def __hash__(self): """Generate a hash unique to all L{RemoteCacheObserver}s for this broker/perspective/cached triplet """ return ( (hash(self.broker) % 2**10) + (hash(self.perspective) % 2**10) + (hash(self.cached) % 2**10)) As we can see, self.cached (which is the pb.Cacheable instance) must be hashable. Why?
4098
Age (days ago)
4098
Last active (days ago)
0 comments
1 participants
participants (1)
-
Daniel Sank