-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-37207: Use PEP 590 vectorcall to speed up tuple() #18936
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
Master ./python.exe -m pyperf timeit "tuple((1, 2, 3, 4, 5))" ..................... Mean +- std dev: 361 ns +- 15 ns PEP-590 ./python.exe -m pyperf timeit "tuple((1, 2, 3, 4, 5))" ..................... Mean +- std dev: 203 ns +- 13 ns
@markshannon @vstinner |
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.
LGTM.
size_t nargsf, PyObject *kwnames) | ||
{ | ||
if (kwnames && PyTuple_GET_SIZE(kwnames) != 0) { | ||
PyErr_Format(PyExc_TypeError, "tuple() takes no keyword arguments"); |
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.
It would be nice to add a function similar to _PyArg_NoKeywords() but accept a kwnames tuple. But it should be done in a separated PR.
return NULL; | ||
} | ||
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); | ||
if (nargs > 1) { |
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 would be nice to have an helper function to raise the exception for use: function taking nargsf and calling PyVectorcall_NARGS() for us. Again, it should be done in a separated PR.
What does Argument Clinic use for that? Does it duplicate the code?
I'm also worried but the Python binary will contains tons of ""xxx takes no keyword arguments" duplicated strings, where only xxx changes. _PyArg_NoKeywords() builds a string from the function name and so doesn't have the issue.
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 agree with your all concerns :)
I will submit the PR to deal with!
Master
PEP-590
https://bugs.python.org/issue37207