Make XModuleDescriptor hashable again (#22501)
This commit is contained in:
@@ -1263,6 +1263,17 @@ class XModuleDescriptor(XModuleDescriptorToXBlockMixin, HTMLSnippet, ResourceTem
|
||||
all(getattr(self, field.name) == getattr(other, field.name)
|
||||
for field in self.fields.values()))
|
||||
|
||||
def __hash__(self): # pylint: disable=useless-super-delegation
|
||||
"""
|
||||
This isn't technically appropriate since descriptors are actually mutable,
|
||||
but in practice we rarely modify them after creation or instantiate two
|
||||
equivalent descriptors in the same process. And we perform graph
|
||||
operations on large collections of XBlocks that have simply unacceptable
|
||||
performance if we have to rely on lists and equality rather than sets,
|
||||
dictionaries, and identity-based hash functions.
|
||||
"""
|
||||
return super(XModuleDescriptor, self).__hash__()
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
"{0.__class__.__name__}("
|
||||
|
||||
Reference in New Issue
Block a user