-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
perf: Reorder conditions in is_leap_year #19602
Conversation
This is a completely random shot as I was just reading polars source code for fun. I can imagine the compiler optimises this anyway but I'd rule out 75 % of cases in the first check rather than 0.25 %.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #19602 +/- ##
=======================================
Coverage 79.84% 79.84%
=======================================
Files 1536 1536
Lines 211405 211405
Branches 2445 2445
=======================================
+ Hits 168790 168797 +7
+ Misses 42060 42053 -7
Partials 555 555 ☔ View full report in Codecov by Sentry. |
@MarcoGorelli can you take a look? |
Makes sense to me that this will be faster; to codify the degree of speedup (and to confirm that the compiler isn't psychic) I checked it with a |
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.
sure, thanks @janpipek , and @alexander-beedie for timing it!
🙏 Thanks for approval and testing. I am glad that it really helped (8% is very nice!). As said, it was more of a random observation. |
Thanks - feel free to make more ;) |
This is a completely random shot as I was just reading polars source code for fun and have no insights into it. I can imagine the rust compiler optimises this anyway but I'd rule out 75 % of cases in the first check rather than 0.25 %.