mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
gh-140009: Improve performance of list_extend_dictitems
by using PyTuple_FromArray
(#140010)
This commit is contained in:
parent
0344db8d60
commit
e6aa515296
2 changed files with 4 additions and 3 deletions
|
@ -0,0 +1 @@
|
|||
Improve performance of list extension by dictionary items.
|
|
@ -1382,9 +1382,9 @@ list_extend_dictitems(PyListObject *self, PyDictObject *dict)
|
|||
PyObject **dest = self->ob_item + m;
|
||||
Py_ssize_t pos = 0;
|
||||
Py_ssize_t i = 0;
|
||||
PyObject *key, *value;
|
||||
while (_PyDict_Next((PyObject *)dict, &pos, &key, &value, NULL)) {
|
||||
PyObject *item = PyTuple_Pack(2, key, value);
|
||||
PyObject *key_value[2];
|
||||
while (_PyDict_Next((PyObject *)dict, &pos, &key_value[0], &key_value[1], NULL)) {
|
||||
PyObject *item = PyTuple_FromArray(key_value, 2);
|
||||
if (item == NULL) {
|
||||
Py_SET_SIZE(self, m + i);
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue