-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
bpo-36781: Optimize sum() for bools. #13074
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
Conversation
| continue; | ||
| } | ||
| if (PyLong_CheckExact(item)) { | ||
| if (PyLong_Check(item)) { |
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.
Why is this not PyLong_CheckExact(item) || PyBool_Check(item) like the one above?
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.
Because why not? This extends the optimization to other int subclasses.
There is a reason why PyLong_Check(item) is not used above: because __radd__ method in the int subclass takes precedence. But for float+int it is not used.
|
@DinoV: Please replace |
* Optimize sum() for bools. * Fix sum([], False). * Add a NEWS entry.
https://bugs.python.org/issue36781