-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-34303: Micro-optimizations in functools.reduce() #8598
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-34303: Micro-optimizations in functools.reduce() #8598
Conversation
Modules/_functoolsmodule.c
Outdated
PyTuple_SetItem(args, 1, op2); | ||
if ((result = PyEval_CallObject(func, args)) == NULL) | ||
Py_XSETREF(PyTuple_GET_ITEM(args, 0), result); | ||
Py_XSETREF(PyTuple_GET_ITEM(args, 1), op2); |
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.
Does PyTuple_GET_ITEM
guarantee its result is an lvalue? That's not in the public API anywhere.
PySequence_Fast_ITEMS(args)[0]
would be conforming to the public API, and I think just as fast
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.
I fixed it, PySequence_Fast_ITEMS()
seems to be slower as it checks for type.
4a0bca9
to
f491abf
Compare
@methane, was there any blocker on merging this? Thanks! |
@rhettinger would you review this? |
https://bugs.python.org/issue34303