reimplement __hash__ with tuple; closes #1
This commit is contained in:
@@ -81,8 +81,8 @@ Tests of hashing:
|
||||
|
||||
>>> v1 = Vector2d(3, 4)
|
||||
>>> v2 = Vector2d(3.1, 4.2)
|
||||
>>> hash(v1), hash(v2)
|
||||
(7, 384307168202284039)
|
||||
>>> hash(v1) != hash(v2)
|
||||
True
|
||||
>>> len(set([v1, v2]))
|
||||
2
|
||||
|
||||
@@ -131,7 +131,7 @@ class Vector2d:
|
||||
|
||||
# BEGIN VECTOR_V3_HASH
|
||||
def __hash__(self):
|
||||
return hash(self.x) ^ hash(self.y)
|
||||
return hash((self.x, self.y))
|
||||
# END VECTOR_V3_HASH
|
||||
|
||||
def __abs__(self):
|
||||
|
||||
Reference in New Issue
Block a user