bpo-37207: Use PEP 590 vectorcall to speed up tuple()#18936
bpo-37207: Use PEP 590 vectorcall to speed up tuple()#18936vstinner merged 2 commits intopython:masterfrom
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 |
| 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.
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.
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.
I agree with your all concerns :)
I will submit the PR to deal with!
Master
PEP-590
https://bugs.python.org/issue37207