-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0248b4
commit 4447577
Showing
5 changed files
with
146 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
============ | ||
Contributors | ||
============ | ||
|
||
* Moshe Malawach <[email protected]> | ||
* Hugo Herter <[email protected]> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import TypeVar, Callable | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class HashWrapper: | ||
""" | ||
A wrapper class to use set operations on objects with an alternate implementation | ||
of __hash__ without modifying the original class. | ||
""" | ||
|
||
def __init__(self, obj: T, hash_func: Callable[[T], int]): | ||
self.obj = obj | ||
self.hash_func = hash_func | ||
|
||
def __hash__(self): | ||
return self.hash_func(self.obj) |