-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
bpo-35588: Speed up mod, divmod and floordiv operations for Fraction type #11322
bpo-35588: Speed up mod, divmod and floordiv operations for Fraction type #11322
Conversation
…pelling out the numerator/denominator calculation, instead of instantiating and normalising Fractions along the way. This speeds up '%' and divmod() by 2-3x.
a8607eb
to
7a624bf
Compare
…rations to make it ~4x faster.
Co-Authored-By: scoder <stefan_ml@behnel.de>
…ision should be an integer.
…r function _flat_divmod() since it's no longer reused.
…_() in order to simplify the implementation, even though performance results are mixed.
Misc/NEWS.d/next/Library/2018-12-26-10-55-59.bpo-35588.PSR6Ez.rst
Outdated
Show resolved
Hide resolved
@serhiy-storchaka the patch looks great for me. |
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.
LGTM. @asvetlov I think is ready to merge.
Co-Authored-By: scoder <stefan_ml@behnel.de>
Misc/NEWS.d/next/Library/2018-12-26-10-55-59.bpo-35588.PSR6Ez.rst
Outdated
Show resolved
Hide resolved
I'll merge this PR after New Year if @rhettinger and @mdickinson do not have objections. |
@serhiy-storchaka: Please replace |
Due to some GitHub bug my edition of the commit message was ignored, and changes were committed with an awful commit message. |
Implement mod and divmod operations for Fraction type by spelling out the numerator/denominator calculation, instead of instantiating and normalising Fractions along the way. This speeds up '%' and divmod() by 2-3x.
https://bugs.python.org/issue35588