Created
December 5, 2024 08:23
-
-
Save dboyliao/047b6673a643f2ced7efb8db0a2f072c to your computer and use it in GitHub Desktop.
Dummy object mimic slow hashing
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
from time import sleep | |
class SlowHashObject: | |
def __init__(self, value): | |
self.value = value | |
def __hash__(self): | |
sleep(0.1) | |
return hash(self.value) | |
def __eq__(self, other): | |
if isinstance(other, SlowHashObject): | |
return self.value == other.value | |
return self.value == other |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment