◐ Shell
clean mode source ↗

bpo-38639: Optimize floor(), ceil() and trunc() for floats. by serhiy-storchaka · Pull Request #16991 · python/cpython

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposed changes LGTM. For things of exact type float (and possibly also for float subclasses), I think we could dispense with the math_1_to_int complications to get even more speedup. But that doesn't have to happen in this PR.

Do we have tests for the various cases of floats, float subclasses that don't override __floor__, float subclasses that do override __floor__, things that aren't floats but provide a __float__ method, etc.? If not, would it be worth adding such tests?