-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Fix hashing behavior #142
Fix hashing behavior #142
Conversation
Codecov Report
@@ Coverage Diff @@
## master #142 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 8 8
Lines 544 551 +7
Branches 119 122 +3
=====================================
+ Hits 544 551 +7
Continue to review full report at Codecov.
|
I'm in favor. I think this will be a clear improvement for 95% of the usage out there. I think we could make the behavior smarter in the default case but honestly I don't know if it's worth the complexity. For example, we can detect if a custom |
Trying to be smarter tends to be recipe for future disaster in my experience. :) I think we should offer explicit APIs for certain archetypes but not try to guess what people want when they set certain flags… |
An observation about compatibility: if the attr.ib list included a a mutable object (say, a dict or a list) is present in the list of hashed attributes, you'd already get an exception. If we don't add a This is "incompatible" in that code which relies on |
f039f42
to
0774042
Compare
Our previous default behavior was incorrect. Adding __hash__ has to be deliberate action and only makes sense for immutable classes. By default, `hash` now mirrors `cmp` which the correct behavior per spec. Fixes #136.
cough Nathaniel? |
It looks like the logic that's implemented here is actually different from my suggestion? Specifically, in the case where if |
No, I just happen too be too dumb to program a computer properly. :( It would be kind if you could have another look… |
I can't say I've read through every line with careful attention, but LGTM |
Thank you for your patience. ❤️ |
Thank you for all your work! |
Our previous default behavior was incorrect. Adding
__hash__
has to be deliberate action and only makes sense for immutable classes.Also set the doc theme to alabaster because the RTD one looks weird if a parameter doc has multiple paragraphs.
cc @njsmith @glyph @Tinche