]> granicus.if.org Git - python/commitdiff
Issue #27809: _csv: _call_dialect() uses fast call
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Aug 2016 22:21:34 +0000 (00:21 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Aug 2016 22:21:34 +0000 (00:21 +0200)
Modules/_csv.c

index ef2e7d78461dcfc2e852cf4b64bff9b3847c3325..7a78541bf2d70a72dac5d6a3e180e5f4b6cca1e7 100644 (file)
@@ -518,15 +518,13 @@ static PyTypeObject Dialect_Type = {
 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);
+    }
 }
 
 /*