Skip to content

Commit 4c461ed

Browse files
Fabien Fleutotvsergeev
authored andcommitted
implement hash special method in Ext class
allowing Ext objects to be used as map keys.
1 parent b7bdf03 commit 4c461ed

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

umsgpack.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ def __str__(self):
123123
s += ")"
124124
return s
125125

126+
def __hash__(self):
127+
"""
128+
Provide a hash of this Ext object.
129+
"""
130+
return hash((self.type, self.data))
131+
132+
126133
class InvalidString(bytes):
127134
"""Subclass of bytes to hold invalid UTF-8 strings."""
128135
pass

0 commit comments

Comments
 (0)