Skip to content
Closed
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 numberDiff line numberDiff line change
@@ -0,0 +1 @@
Improve performance of dict object by replacing PyTuple_Pack with PyTuple_FromArray for small tuples.
6 changes: 4 additions & 2 deletions Objects/dictobject.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -5083,7 +5083,8 @@ dictiter_new(PyDictObject *dict, PyTypeObject *itertype)
}
if (itertype == &PyDictIterItem_Type ||
itertype == &PyDictRevIterItem_Type) {
di->di_result = PyTuple_Pack(2, Py_None, Py_None);
PyObject *items[] = {Py_None, Py_None};
di->di_result = PyTuple_FromArray(items, 2);
if (di->di_result == NULL) {
Py_DECREF(di);
return NULL;
Expand DownExpand Up@@ -6284,7 +6285,8 @@ dictitems_xor_lock_held(PyObject *d1, PyObject *d2)
}
}
else {
PyObject *pair = PyTuple_Pack(2, key, val2);
PyObject *items[] = {key, val2};
PyObject *pair = PyTuple_FromArray(items, 2);
if (pair == NULL) {
goto error;
}
Expand Down
Loading