Clarify why there's a ShardRange.__hash__
Change-Id: I4eff901aaa334c8a73cebfc578cea14d23e6c365
This commit is contained in:
@@ -4336,11 +4336,13 @@ class ShardRange(Namespace):
|
|||||||
self.timestamp = timestamp or Timestamp.now()
|
self.timestamp = timestamp or Timestamp.now()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# A by-the-book implementation should probably hash the value, which
|
# It's a little funny that we're making this mutable class hashable, but
|
||||||
# in our case would be account+container+lower+upper (+timestamp ?).
|
# we want to be able to map donor -> acceptor, shard range -> broker, etc.
|
||||||
# But we seem to be okay with just the identity.
|
# Since we override __eq__, we don't get Python's hashable-by-default,
|
||||||
def __hash__(self):
|
# but we are happy to use their hash-derived-from-id().
|
||||||
return id(self)
|
# NB: this breaks Python's assumption that "Hashable objects which compare
|
||||||
|
# equal must have the same hash value."
|
||||||
|
__hash__ = object.__hash__
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s<%r to %r as of %s, (%d, %d) as of %s, %s as of %s>' % (
|
return '%s<%r to %r as of %s, (%d, %d) as of %s, %s as of %s>' % (
|
||||||
|
|||||||
Reference in New Issue
Block a user