Skip to content

Commit

Permalink
Change Resource dunder hash to reduce collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
dgetu committed May 25, 2021
1 parent 5e1a565 commit 32ce848
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def __eq__(self, other: object) -> bool:
)

def __hash__(self):
return hash(dumps(self._attributes, sort_keys=True) + self._schema_url)
return hash(dumps(self._attributes, sort_keys=True)) + 31 * hash(
self._schema_url
)


_EMPTY_RESOURCE = Resource({}, "")
Expand Down

0 comments on commit 32ce848

Please sign in to comment.