Uh oh!
There was an error while loading. Please reload this page.
bpo-38629: implement __floor__ and __ceil__ for float - #16985
Conversation
vstinner
left a comment
There was a problem hiding this comment.
What is the performance impact on math.floor(1.0) and math.ceil(1.0)? Faster, slower, no significant impact?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
mdickinson
commented
Oct 29, 2019
This PR needs tests. |
There was a problem hiding this comment.
Thanks for this PR. Some changes are needed:
- The PR needs unit tests.
- The implementations won't do the right thing on machines with 32-bit longs: there's no adjustment for non-integer values in the non-fast path.
- As @vstinner suggested, it would be much simpler to just use the
libmfunctionsceilandfloor. - There's no real need for the fast path, given #15611: I'd suggest dropping that and simply sending the output of
ceilandfloorintoPyLong_FromDouble.
bedevere-bot
commented
Oct 29, 2019
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
isidentical
commented
Oct 30, 2019
I have made the requested changes; please review again |
bedevere-bot
commented
Oct 30, 2019
Thanks for making the requested changes! @mdickinson: please review the changes made to this pull request. |
isidentical
commented
Oct 30, 2019
I submitted benchmarks to bpo |
mdickinson
left a comment
There was a problem hiding this comment.
Changes LGTM; thank you! The performance is still a concern, but if some form of #16991 gets merged then that wouldn't be so much of an issue.
@serhiy-storchaka@vstinner Does the current state of the PR seem okay to you?
Uh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka
commented
Oct 30, 2019
#16991 will solve the performance issue for exact floats, but not for subclasses. |
mdickinson
commented
Oct 31, 2019
I don't think there's too much reason to care about fine-tuning of performance for |
vstinner
commented
Dec 5, 2019
me:
I checked the current implementation of math.floor(): there is a fast-path for exact type float which does something like I'm fine with calling the |
vstinner
commented
Dec 5, 2019
Oh, that's @serhiy-storchaka 's PR #16991 which has just been merged. I didn't notice ;-) |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. There is no performance overhead on math.floor() and math.ceil() for exact float.
I'm fine with having a small overhead for float subclasses. I didn't measure the overhead, I expect it to be really small or even not significant.
vstinner
commented
Dec 5, 2019
@mdickinson@serhiy-storchaka: I'm not sure that you agree, so I didn't merge the PR. I approve the PR, so I'm fine with merging it. What about you? |
vstinner
commented
Dec 14, 2019
@mdickinson@serhiy-storchaka: I plan to merge this PR next Friday (December 21) if no one replies. @isidentical: Please ping me next Friday if I forget to merge your PR. |
mdickinson
commented
Dec 15, 2019
@vstinner Merging is fine with me. |
https://bugs.python.org/issue38629