Skip to content

bpo-39434: Improve float __floordiv__ performance and error message #18147

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

Merged
merged 1 commit into from
Jan 30, 2020

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Jan 23, 2020

@corona10 corona10 changed the title [WIP] bpo-39434: Add float __floordiv__ fast path bpo-39434: Add float __floordiv__ fast path Jan 23, 2020
@corona10
Copy link
Member Author

@mdickinson, @vstinner
If this proposal is accepted, I am going to add news.d since the error message is changed.

@corona10 corona10 changed the title bpo-39434: Add float __floordiv__ fast path bpo-39434: Remove unnecessary logic of float __floordiv__ Jan 23, 2020
Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

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

Neat trick: I was worried about duplicated code (see the issue discussion), but it seems we can rely on the compiler to inline _float_div_mod and then strip out the redundant stuff.

LGTM

@mdickinson
Copy link
Member

Is there benefit to applying the same approach to float_rem? Apart from the possibility of a performance boost, it looks as though it would actually make the code simpler (removing existing duplication) and safer. And for floats, % is possibly used more often than // (for argument reduction, for example).

@mdickinson
Copy link
Member

Apart from the possibility of a performance boost,

Sorry, of course that doesn't apply, since float_rem is already special-cased and doesn't go via divmod.

@corona10 corona10 changed the title bpo-39434: Remove unnecessary logic of float __floordiv__ bpo-39434: Improve float __floordiv__ performance and update error message Jan 24, 2020
@corona10 corona10 changed the title bpo-39434: Improve float __floordiv__ performance and update error message bpo-39434: Improve float __floordiv__ performance and error message Jan 24, 2020
@corona10
Copy link
Member Author

@vstinner @pablogsal If you don't mind can you please take a look? :)

@mdickinson
Copy link
Member

I've done some manual testing as well as reviewing. Still LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants