Skip to content

Commit

Permalink
PyFile_WriteObject() now uses fast call
Browse files Browse the repository at this point in the history
Issue python#27128: PyFile_WriteObject() now calls _PyObject_FastCall() to avoid the
creation of a temporary tuple.
  • Loading branch information
vstinner committed Aug 19, 2016
1 parent 7521069 commit 9def090
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions Objects/fileobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ PyFile_GetLine(PyObject *f, int n)
int
PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
{
PyObject *writer, *value, *args, *result;
PyObject *writer, *value, *result;
_Py_IDENTIFIER(write);

if (f == NULL) {
Expand All @@ -146,14 +146,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
Py_DECREF(writer);
return -1;
}
args = PyTuple_Pack(1, value);
if (args == NULL) {
Py_DECREF(value);
Py_DECREF(writer);
return -1;
}
result = PyEval_CallObject(writer, args);
Py_DECREF(args);
result = _PyObject_FastCall(writer, &value, 1, NULL);
Py_DECREF(value);
Py_DECREF(writer);
if (result == NULL)
Expand Down

0 comments on commit 9def090

Please sign in to comment.