GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-37207: Use vertorcall for list() by encukou · Pull Request #18928 · python/cpython Conversation
|
| list_vectorcall(PyObject *type, PyObject * const*args, | ||
| size_t nargsf, PyObject *kwnames) | ||
| { | ||
| if (kwnames && PyTuple_GET_SIZE(kwnames) != 0) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Since #18980 is merged.
We can replace the logic into
if (!_PyArg_NoKwnames("list", kwnames)) { return NULL; }
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return NULL; | ||
| } | ||
| Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); | ||
| if (nargs > 1) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We can replace it into
if (!_PyArg_CheckPositional("list", nargs, 0, 1)) { return NULL; }
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return NULL; | ||
| } | ||
|
|
||
| assert(PyType_Check(type)); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you move this assert into the top of the function body since this parameter is the 1st parameter?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't see why that's necessary.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change :)
lgtm
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@corona10 @encukou: Can one of you please run a benchmark? @markshannon wrote "As an initial step, we can speed up calls to range, list and dict by about 30%." at https://bugs.python.org/issue37207#msg345077 but I would prefer to see directly results of a microbenchmarks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. But it would be better if someone can benchmark this optimization ;-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@vstinner It shows a similar enhancement to the collections to which this feature is applied. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ok, 1.15x faster (-13%) and -118 nanoseconds looks worth it to me. list(iterable) is commonly used. Again, LGTM ;-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I merged the PR, thanks @markshannon, @encukou and @corona10 ;-) There was an interesting typo: "vertorcall call" :-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.