[Python-checkins] cpython: PyEval_CallObjectWithKeywords() uses fast call with kwargs

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


https://hg.python.org/cpython/rev/ef0110a52e24
changeset:   102845:ef0110a52e24
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Aug 22 23:26:00 2016 +0200
summary:
  PyEval_CallObjectWithKeywords() uses fast call with kwargs

Issue #27809. _PyObject_FastCallDict() now supports keyword arguments, and so
the args==NULL fast-path can also be used when kwargs is not NULL.

files:
  Python/ceval.c |  16 ++++------------
  1 files changed, 4 insertions(+), 12 deletions(-)


diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4590,30 +4590,22 @@
 #endif
 
     if (args == NULL) {
-        if (kwargs == NULL) {
-            return _PyObject_CallNoArg(func);
-        }
-
-        args = PyTuple_New(0);
-        if (args == NULL)
-            return NULL;
+        return _PyObject_FastCallDict(func, NULL, 0, kwargs);
     }
-    else if (!PyTuple_Check(args)) {
+
+    if (!PyTuple_Check(args)) {
         PyErr_SetString(PyExc_TypeError,
                         "argument list must be a tuple");
         return NULL;
     }
-    else {
-        Py_INCREF(args);
-    }
 
     if (kwargs != NULL && !PyDict_Check(kwargs)) {
         PyErr_SetString(PyExc_TypeError,
                         "keyword list must be a dictionary");
-        Py_DECREF(args);
         return NULL;
     }
 
+    Py_INCREF(args);
     result = PyObject_Call(func, args, kwargs);
     Py_DECREF(args);
 

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


More information about the Python-checkins mailing list