gh-145192: Improve performance of PySequence_GetSlice#145193
gh-145192: Improve performance of PySequence_GetSlice#145193eendebakpt wants to merge 9 commits intopython:mainfrom
Conversation
|
Looks good. |
|
|
||
| static PySliceObject * | ||
| _PyBuildSlice_Consume2(PyObject *start, PyObject *stop, PyObject *step) | ||
| _PyBuildSlice_Consume3(PyObject *start, PyObject *stop, PyObject *step) |
There was a problem hiding this comment.
Since this consumes all its argument references, the 3 is unnecessary
There was a problem hiding this comment.
In fact, this is now the same as _PyBuildSlice_ConsumeRefs, so you can rename this function and delete the other definition of _PyBuildSlice_ConsumeRefs
There was a problem hiding this comment.
The _PyBuildSlice_ConsumeRefs only takes 2 arguments. I can delete it, but it would involve some churn (e.g. in bytecodes.c) because we have to add Py_None as a third argument.
|
This PR is stale because it has been open for 30 days with no activity. |
PySequence_GetSliceby avoiding an incref/decref pairs in_PySlice_FromIndices_PyBuildSlice_Consume2is refactored so that in consumes references. Before it had the funny property of consuming refs of the the first 2 two slice arguments, but not of the last._PyBuildSlice_ConsumeRefs(used in the opcode_BINARY_SLICE) avoids an incref onPy_NoneThe
PySequence_GetSliceis part of the C api, with no direct equivalent from Python, so the benchmark is in C.Main:
PR
Benchmark details
Run with optimized FT build.
Code: