Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Speed up frame local variable item collection by appending result pairs to the
output list without an extra reference-count round-trip (using the internal
reference-stealing list append helper). Patch by Omkar Kabde.
9 changes: 3 additions & 6 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "pycore_function.h" // _PyFunction_FromConstructor()
#include "pycore_genobject.h" // _PyGen_GetGeneratorFromFrame()
#include "pycore_interpframe.h" // _PyFrame_GetLocalsArray()
#include "pycore_list.h" // _PyList_AppendTakeRef()
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "pycore_opcode_metadata.h" // _PyOpcode_Caches
Expand Down Expand Up @@ -636,9 +637,7 @@ framelocalsproxy_items(PyObject *self, PyObject *Py_UNUSED(ignored))
goto error;
}

int rc = PyList_Append(items, pair);
Py_DECREF(pair);
if (rc < 0) {
if (_PyList_AppendTakeRef((PyListObject *)items, pair) < 0) {
goto error;
}
}
Expand All @@ -655,9 +654,7 @@ framelocalsproxy_items(PyObject *self, PyObject *Py_UNUSED(ignored))
goto error;
}

int rc = PyList_Append(items, pair);
Py_DECREF(pair);
if (rc < 0) {
if (_PyList_AppendTakeRef((PyListObject *)items, pair) < 0) {
goto error;
}
}
Expand Down
Loading