-
-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inheriting from a frozen class causes instantiated child hashes to collide #528
Comments
@EdwardJB : The behavior seems more general than this.
If you look at how the hash is computed, the type appears not to be used anywhere (despite the name While the behavior might seem a little odd, it isn't wrong (since there are no hard guarantees about hash code collisions even for objects of the same type) and it is difficult for me to imagine a case where it has significant performance implications. (to compare to a similar library, sampling some generated code from Java's Immutables indicates they do not incorporate the class into the hash code either) |
It seems good to at least rename |
And the footnote on http://www.attrs.org/en/stable/hashing.html#id1 which says "The hash is computed by hashing a tuple that consists of an unique id for the class plus all attribute values" doesn't match the actual behavior. |
That's what I was relying on. Can you guys add an |
@EdwardJB : well, that's up to @hynek , etc. I'm just a random person. :-) . But I'm a little curious what your use case is where this matters? The only impact would be increasing the collision rate for collections which contain lots of objects which have identical content except for their type. I'm having a hard time imagining a circumstance which would require this? |
Multiple things:
|
This works as expected:
This errors:
So these two instantiated classes hash to the same value despite a) being instances of different classes and b) being of classes which, when uninstantiated, have differing hashes.
This seems very wrong to me!
The text was updated successfully, but these errors were encountered: