We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 24e2362 commit e281176Copy full SHA for e281176
unpythonic/llist.py
@@ -193,7 +193,11 @@ def __eq__(self, other):
193
return self.car == other.car and self.cdr == other.cdr
194
return False
195
def __hash__(self):
196
- return hash((hash(self.car), hash(self.cdr)))
+ try: # duck test linked list
197
+ tpl = tuple(self)
198
+ except TypeError:
199
+ tpl = (self.car, self.cdr)
200
+ return hash(tpl)
201
202
def _car(x):
203
return _typecheck(x).car
0 commit comments