]> granicus.if.org Git - python/commitdiff
PyFile_WriteObject() now uses fast call
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 22:44:04 +0000 (00:44 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 22:44:04 +0000 (00:44 +0200)
Issue #27128: PyFile_WriteObject() now calls _PyObject_FastCall() to avoid the
creation of a temporary tuple.

Objects/fileobject.c

index 234d07e5c6754d4df2646c13f21875e4f5a67bd1..83348a8ee3c79adbd04ec16d34eaffa934690519 100644 (file)
@@ -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) {
@@ -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)