Skip to content
Closed
Changes from 1 commit
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
Next Next commit
Optimize dict object by replacing PyTuple_Pack with PyTuple_FromArray
  • Loading branch information
rashestripathy
rashestripathy committed Feb 5, 2026
commit b94bc717067f55d322ab510255ea7ce1b384e862
6 changes: 4 additions & 2 deletions Objects/dictobject.c
Original file line number Diff line number Diff 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 Down Expand 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