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

Skip to content

Commit 9def090

Browse files
committed
PyFile_WriteObject() now uses fast call
Issue #27128: PyFile_WriteObject() now calls _PyObject_FastCall() to avoid the creation of a temporary tuple.
1 parent 7521069 commit 9def090

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

Objects/fileobject.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ PyFile_GetLine(PyObject *f, int n)
127127
int
128128
PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
129129
{
130-
PyObject *writer, *value, *args, *result;
130+
PyObject *writer, *value, *result;
131131
_Py_IDENTIFIER(write);
132132

133133
if (f == NULL) {
@@ -146,14 +146,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
146146
Py_DECREF(writer);
147147
return -1;
148148
}
149-
args = PyTuple_Pack(1, value);
150-
if (args == NULL) {
151-
Py_DECREF(value);
152-
Py_DECREF(writer);
153-
return -1;
154-
}
155-
result = PyEval_CallObject(writer, args);
156-
Py_DECREF(args);
149+
result = _PyObject_FastCall(writer, &value, 1, NULL);
157150
Py_DECREF(value);
158151
Py_DECREF(writer);
159152
if (result == NULL)

0 commit comments

Comments
 (0)