-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Speed up __eq__ #1310
Speed up __eq__ #1310
Conversation
CodSpeed Performance ReportMerging #1310 will improve performances by 63.24%Comparing Summary
Benchmarks breakdown
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool thanks! 🏎️
You might want to update the comment above those lines that says we can't do exactly what we're doing now 😄 Lines 1535 to 1536 in 13e9a6a
|
thanks, it's so hard to find quality free labor 🤪 |
Create the
__eq__
as a chain of ANDed comparisons, instead of a tuple.On my computer, a class with two attributes now compares almost twice as fast: 141 ns vs 222 ns.
This will introduce a very slight incompatibility which I think is worth it for us (and dataclasses already introduced): attributes that compare equal by identity but not by value (= NaNs) will behave differently.