[Python-checkins] cpython: Issue #27809: _csv: _call_dialect() uses fast call

victor.stinner python-checkins at python.org
Mon Aug 22 18:32:46 EDT 2016


https://hg.python.org/cpython/rev/f48ae71e8a8f
changeset:   102850:f48ae71e8a8f
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Aug 23 00:21:34 2016 +0200
summary:
  Issue #27809: _csv: _call_dialect() uses fast call

files:
  Modules/_csv.c |  16 +++++++---------
  1 files changed, 7 insertions(+), 9 deletions(-)


diff --git a/Modules/_csv.c b/Modules/_csv.c
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -518,15 +518,13 @@
 static PyObject *
 _call_dialect(PyObject *dialect_inst, PyObject *kwargs)
 {
-    PyObject *ctor_args;
-    PyObject *dialect;
-
-    ctor_args = Py_BuildValue(dialect_inst ? "(O)" : "()", dialect_inst);
-    if (ctor_args == NULL)
-        return NULL;
-    dialect = PyObject_Call((PyObject *)&Dialect_Type, ctor_args, kwargs);
-    Py_DECREF(ctor_args);
-    return dialect;
+    PyObject *type = (PyObject *)&Dialect_Type;
+    if (dialect_inst) {
+        return _PyObject_FastCallDict(type, &dialect_inst, 1, kwargs);
+    }
+    else {
+        return _PyObject_FastCallDict(type, NULL, 0, kwargs);
+    }
 }
 
 /*

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list