Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7fbac45

Browse files
committed
_elementtree: deepcopy() now uses fast call
Issue #27128.
1 parent c3ccaae commit 7fbac45

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

Modules/_elementtree.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,8 @@ LOCAL(PyObject *)
819819
deepcopy(PyObject *object, PyObject *memo)
820820
{
821821
/* do a deep copy of the given object */
822-
PyObject *args;
823-
PyObject *result;
824822
elementtreestate *st;
823+
PyObject *stack[2];
825824

826825
/* Fast paths */
827826
if (object == Py_None || PyUnicode_CheckExact(object)) {
@@ -857,12 +856,9 @@ deepcopy(PyObject *object, PyObject *memo)
857856
return NULL;
858857
}
859858

860-
args = PyTuple_Pack(2, object, memo);
861-
if (!args)
862-
return NULL;
863-
result = PyObject_CallObject(st->deepcopy_obj, args);
864-
Py_DECREF(args);
865-
return result;
859+
stack[0] = object;
860+
stack[1] = memo;
861+
return _PyObject_FastCall(st->deepcopy_obj, stack, 2, NULL);
866862
}
867863

868864

0 commit comments

Comments
 (0)