attrs
attrs copied to clipboard
Allow to pass a callable for field-level hash
Apparently, being able to customize the hashing of individual fields is something interesting for NumPy users: https://stackoverflow.com/q/74975393/476759
I guess the idea would be to create a __hash__ that looks like this:
def __hash__(self):
return hash((self.a, custom_hash_for_b(self.b)))
while injecting custom_hash_for_b into eval's globals.
Don't be a coward and inject it into __hash__ as a parameter default.