[Python-checkins] cpython: Replace PyObject_CallFunctionObjArgs() with fastcall

victor.stinner python-checkins at python.org
Thu Dec 1 09:09:47 EST 2016


https://hg.python.org/cpython/rev/b9c9691c72c5
changeset:   105402:b9c9691c72c5
parent:      105399:20bb8babc505
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Dec 01 14:43:22 2016 +0100
summary:
  Replace PyObject_CallFunctionObjArgs() with fastcall

* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func)
* PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg)

PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires
extra work to "parse" C arguments to build a C array of PyObject*.

_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.

This change is part of the fastcall project. The change on listsort() is
related to the issue #23507.

files:
  Modules/_asynciomodule.c  |  12 +++++-------
  Modules/_csv.c            |   2 +-
  Modules/_elementtree.c    |   2 +-
  Modules/_json.c           |  12 ++++++------
  Modules/_ssl.c            |   2 +-
  Modules/_struct.c         |   2 +-
  Modules/_testbuffer.c     |  10 +++++-----
  Modules/gcmodule.c        |   2 +-
  Modules/itertoolsmodule.c |  10 +++++-----
  Modules/mathmodule.c      |   6 +++---
  Modules/posixmodule.c     |   4 ++--
  Objects/abstract.c        |   8 ++++----
  Objects/bytearrayobject.c |   6 ++----
  Objects/bytesobject.c     |   7 +++----
  Objects/complexobject.c   |   2 +-
  Objects/descrobject.c     |   2 +-
  Objects/dictobject.c      |   3 +--
  Objects/enumobject.c      |   2 +-
  Objects/floatobject.c     |   2 +-
  Objects/genobject.c       |   4 ++--
  Objects/listobject.c      |   3 +--
  Objects/longobject.c      |   3 +--
  Objects/memoryobject.c    |   4 ++--
  Objects/object.c          |   4 ++--
  Objects/odictobject.c     |   2 +-
  Objects/typeobject.c      |   6 ++----
  Objects/unicodeobject.c   |  10 ++++------
  Objects/weakrefobject.c   |   2 +-
  Python/_warnings.c        |   2 +-
  Python/bltinmodule.c      |   8 ++++----
  Python/ceval.c            |   6 +++---
  Python/import.c           |   2 +-
  Python/sysmodule.c        |   2 +-
  33 files changed, 71 insertions(+), 83 deletions(-)


diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -721,8 +721,7 @@
 _asyncio_Future__repr_info_impl(FutureObj *self)
 /*[clinic end generated code: output=fa69e901bd176cfb input=f21504d8e2ae1ca2]*/
 {
-    return PyObject_CallFunctionObjArgs(
-        asyncio_future_repr_info_func, self, NULL);
+    return _PyObject_CallArg1(asyncio_future_repr_info_func, self);
 }
 
 /*[clinic input]
@@ -1535,8 +1534,7 @@
 _asyncio_Task__repr_info_impl(TaskObj *self)
 /*[clinic end generated code: output=6a490eb66d5ba34b input=3c6d051ed3ddec8b]*/
 {
-    return PyObject_CallFunctionObjArgs(
-        asyncio_task_repr_info_func, self, NULL);
+    return _PyObject_CallArg1(asyncio_task_repr_info_func, self);
 }
 
 /*[clinic input]
@@ -1896,7 +1894,7 @@
         return NULL;
     }
 
-    PyObject *e = PyObject_CallFunctionObjArgs(et, msg, NULL);
+    PyObject *e = _PyObject_CallArg1(et, msg);
     Py_DECREF(msg);
     if (e == NULL) {
         return NULL;
@@ -1946,7 +1944,7 @@
 
         if (!exc) {
             /* exc was not a CancelledError */
-            exc = PyObject_CallFunctionObjArgs(asyncio_CancelledError, NULL);
+            exc = _PyObject_CallNoArg(asyncio_CancelledError);
             if (!exc) {
                 goto fail;
             }
@@ -2176,7 +2174,7 @@
     }
 
     /* Check if `result` is a generator */
-    o = PyObject_CallFunctionObjArgs(inspect_isgenerator, result, NULL);
+    o = _PyObject_CallArg1(inspect_isgenerator, result);
     if (o == NULL) {
         /* An exception in inspect.isgenerator */
         goto fail;
diff --git a/Modules/_csv.c b/Modules/_csv.c
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -1259,7 +1259,7 @@
                                      (void *) self->rec, self->rec_len);
     if (line == NULL)
         return NULL;
-    result = PyObject_CallFunctionObjArgs(self->writeline, line, NULL);
+    result = _PyObject_CallArg1(self->writeline, line);
     Py_DECREF(line);
     return result;
 }
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -2457,7 +2457,7 @@
         PyObject *event = PyTuple_Pack(2, action, node);
         if (event == NULL)
             return -1;
-        res = PyObject_CallFunctionObjArgs(self->events_append, event, NULL);
+        res = _PyObject_CallArg1(self->events_append, event);
         Py_DECREF(event);
         if (res == NULL)
             return -1;
diff --git a/Modules/_json.c b/Modules/_json.c
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -813,14 +813,14 @@
     *next_idx_ptr = idx + 1;
 
     if (has_pairs_hook) {
-        val = PyObject_CallFunctionObjArgs(s->object_pairs_hook, rval, NULL);
+        val = _PyObject_CallArg1(s->object_pairs_hook, rval);
         Py_DECREF(rval);
         return val;
     }
 
     /* if object_hook is not None: rval = object_hook(rval) */
     if (s->object_hook != Py_None) {
-        val = PyObject_CallFunctionObjArgs(s->object_hook, rval, NULL);
+        val = _PyObject_CallArg1(s->object_hook, rval);
         Py_DECREF(rval);
         return val;
     }
@@ -924,7 +924,7 @@
         return NULL;
 
     /* rval = parse_constant(constant) */
-    rval = PyObject_CallFunctionObjArgs(s->parse_constant, cstr, NULL);
+    rval = _PyObject_CallArg1(s->parse_constant, cstr);
     idx += PyUnicode_GET_LENGTH(cstr);
     Py_DECREF(cstr);
     *next_idx_ptr = idx;
@@ -1023,7 +1023,7 @@
                                            idx - start);
         if (numstr == NULL)
             return NULL;
-        rval = PyObject_CallFunctionObjArgs(custom_func, numstr, NULL);
+        rval = _PyObject_CallArg1(custom_func, numstr);
     }
     else {
         Py_ssize_t i, n;
@@ -1475,7 +1475,7 @@
     if (s->fast_encode)
         return s->fast_encode(NULL, obj);
     else
-        return PyObject_CallFunctionObjArgs(s->encoder, obj, NULL);
+        return _PyObject_CallArg1(s->encoder, obj);
 }
 
 static int
@@ -1553,7 +1553,7 @@
                 return -1;
             }
         }
-        newobj = PyObject_CallFunctionObjArgs(s->defaultfn, obj, NULL);
+        newobj = _PyObject_CallArg1(s->defaultfn, obj);
         if (newobj == NULL) {
             Py_XDECREF(ident);
             return -1;
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -3197,7 +3197,7 @@
     PySSL_END_ALLOW_THREADS_S(pw_info->thread_state);
 
     if (pw_info->callable) {
-        fn_ret = PyObject_CallFunctionObjArgs(pw_info->callable, NULL);
+        fn_ret = _PyObject_CallNoArg(pw_info->callable);
         if (!fn_ret) {
             /* TODO: It would be nice to move _ctypes_add_traceback() into the
                core python API, so we could use it to add a frame here */
diff --git a/Modules/_struct.c b/Modules/_struct.c
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -2046,7 +2046,7 @@
         return s_object;
     }
 
-    s_object = PyObject_CallFunctionObjArgs((PyObject *)(&PyStructType), fmt, NULL);
+    s_object = _PyObject_CallArg1((PyObject *)(&PyStructType), fmt);
     if (s_object != NULL) {
         if (PyDict_Size(cache) >= MAXCACHE)
             PyDict_Clear(cache);
diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c
--- a/Modules/_testbuffer.c
+++ b/Modules/_testbuffer.c
@@ -312,7 +312,7 @@
     assert(PyObject_CheckBuffer(obj));
     assert(PyList_Check(items) || PyTuple_Check(items));
 
-    structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL);
+    structobj = _PyObject_CallArg1(Struct, format);
     if (structobj == NULL)
         return -1;
 
@@ -406,7 +406,7 @@
     if (format == NULL)
         goto out;
 
-    structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL);
+    structobj = _PyObject_CallArg1(Struct, format);
     if (structobj == NULL)
         goto out;
 
@@ -620,7 +620,7 @@
 
     if (ndim == 0) {
         memcpy(item, ptr, itemsize);
-        x = PyObject_CallFunctionObjArgs(unpack_from, mview, NULL);
+        x = _PyObject_CallArg1(unpack_from, mview);
         if (x == NULL)
             return NULL;
         if (PyTuple_GET_SIZE(x) == 1) {
@@ -696,7 +696,7 @@
     if (format == NULL)
         goto out;
 
-    structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL);
+    structobj = _PyObject_CallArg1(Struct, format);
     Py_DECREF(format);
     if (structobj == NULL)
         goto out;
@@ -788,7 +788,7 @@
     PyObject *tmp;
     Py_ssize_t itemsize;
 
-    tmp = PyObject_CallFunctionObjArgs(calcsize, format, NULL);
+    tmp = _PyObject_CallArg1(calcsize, format);
     if (tmp == NULL)
         return -1;
     itemsize = PyLong_AsSsize_t(tmp);
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -709,7 +709,7 @@
         assert(callback != NULL);
 
         /* copy-paste of weakrefobject.c's handle_callback() */
-        temp = PyObject_CallFunctionObjArgs(callback, wr, NULL);
+        temp = _PyObject_CallArg1(callback, wr);
         if (temp == NULL)
             PyErr_WriteUnraisable(callback);
         else
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -101,7 +101,7 @@
             newkey = newvalue;
             Py_INCREF(newvalue);
         } else {
-            newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc, newvalue, NULL);
+            newkey = _PyObject_CallArg1(gbo->keyfunc, newvalue);
             if (newkey == NULL) {
                 Py_DECREF(newvalue);
                 return NULL;
@@ -293,7 +293,7 @@
             newkey = newvalue;
             Py_INCREF(newvalue);
         } else {
-            newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc, newvalue, NULL);
+            newkey = _PyObject_CallArg1(gbo->keyfunc, newvalue);
             if (newkey == NULL) {
                 Py_DECREF(newvalue);
                 return NULL;
@@ -1130,7 +1130,7 @@
         if (lz->start == 1)
             return item;
 
-        good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
+        good = _PyObject_CallArg1(lz->func, item);
         if (good == NULL) {
             Py_DECREF(item);
             return NULL;
@@ -1296,7 +1296,7 @@
     if (item == NULL)
         return NULL;
 
-    good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
+    good = _PyObject_CallArg1(lz->func, item);
     if (good == NULL) {
         Py_DECREF(item);
         return NULL;
@@ -3824,7 +3824,7 @@
             ok = PyObject_IsTrue(item);
         } else {
             PyObject *good;
-            good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
+            good = _PyObject_CallArg1(lz->func, item);
             if (good == NULL) {
                 Py_DECREF(item);
                 return NULL;
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -951,7 +951,7 @@
             return NULL;
         return math_1_to_int(number, ceil, 0);
     }
-    result = PyObject_CallFunctionObjArgs(method, NULL);
+    result = _PyObject_CallNoArg(method);
     Py_DECREF(method);
     return result;
 }
@@ -991,7 +991,7 @@
             return NULL;
         return math_1_to_int(number, floor, 0);
     }
-    result = PyObject_CallFunctionObjArgs(method, NULL);
+    result = _PyObject_CallNoArg(method);
     Py_DECREF(method);
     return result;
 }
@@ -1542,7 +1542,7 @@
                          Py_TYPE(number)->tp_name);
         return NULL;
     }
-    result = PyObject_CallFunctionObjArgs(trunc, NULL);
+    result = _PyObject_CallNoArg(trunc);
     Py_DECREF(trunc);
     return result;
 }
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -902,7 +902,7 @@
             goto error_exit;
         }
 
-        o = to_cleanup = PyObject_CallFunctionObjArgs(func, NULL);
+        o = to_cleanup = _PyObject_CallNoArg(func);
         Py_DECREF(func);
         if (NULL == o) {
             goto error_exit;
@@ -12041,7 +12041,7 @@
                             Py_TYPE(path)->tp_name);
     }
 
-    path_repr = PyObject_CallFunctionObjArgs(func, NULL);
+    path_repr = _PyObject_CallNoArg(func);
     Py_DECREF(func);
     if (NULL == path_repr) {
         return NULL;
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -103,7 +103,7 @@
         }
         return defaultvalue;
     }
-    result = PyObject_CallFunctionObjArgs(hint, NULL);
+    result = _PyObject_CallNoArg(hint);
     Py_DECREF(hint);
     if (result == NULL) {
         if (PyErr_ExceptionMatches(PyExc_TypeError)) {
@@ -716,7 +716,7 @@
     }
 
     /* And call it. */
-    result = PyObject_CallFunctionObjArgs(meth, format_spec, NULL);
+    result = _PyObject_CallArg1(meth, format_spec);
     Py_DECREF(meth);
 
     if (result && !PyUnicode_Check(result)) {
@@ -3011,7 +3011,7 @@
             Py_DECREF(checker);
             return ok;
         }
-        res = PyObject_CallFunctionObjArgs(checker, inst, NULL);
+        res = _PyObject_CallArg1(checker, inst);
         Py_LeaveRecursiveCall();
         Py_DECREF(checker);
         if (res != NULL) {
@@ -3085,7 +3085,7 @@
             Py_DECREF(checker);
             return ok;
         }
-        res = PyObject_CallFunctionObjArgs(checker, derived, NULL);
+        res = _PyObject_CallArg1(checker, derived);
         Py_LeaveRecursiveCall();
         Py_DECREF(checker);
         if (res != NULL) {
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -98,8 +98,7 @@
 PyObject *
 PyByteArray_FromObject(PyObject *input)
 {
-    return PyObject_CallFunctionObjArgs((PyObject *)&PyByteArray_Type,
-                                        input, NULL);
+    return _PyObject_CallArg1((PyObject *)&PyByteArray_Type, input);
 }
 
 PyObject *
@@ -1985,8 +1984,7 @@
 {
     PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type);
     if (type != &PyByteArray_Type && result != NULL) {
-        Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type,
-                                                       result, NULL));
+        Py_SETREF(result, _PyObject_CallArg1((PyObject *)type, result));
     }
     return result;
 }
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -549,7 +549,7 @@
     /* does it support __bytes__? */
     func = _PyObject_LookupSpecial(v, &PyId___bytes__);
     if (func != NULL) {
-        result = PyObject_CallFunctionObjArgs(func, NULL);
+        result = _PyObject_CallNoArg(func);
         Py_DECREF(func);
         if (result == NULL)
             return NULL;
@@ -2331,8 +2331,7 @@
 {
     PyObject *result = _PyBytes_FromHex(string, 0);
     if (type != &PyBytes_Type && result != NULL) {
-        Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type,
-                                                       result, NULL));
+        Py_SETREF(result, _PyObject_CallArg1((PyObject *)type, result));
     }
     return result;
 }
@@ -2569,7 +2568,7 @@
        PyObject_Bytes doesn't do. */
     func = _PyObject_LookupSpecial(x, &PyId___bytes__);
     if (func != NULL) {
-        new = PyObject_CallFunctionObjArgs(func, NULL);
+        new = _PyObject_CallNoArg(func);
         Py_DECREF(func);
         if (new == NULL)
             return NULL;
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -273,7 +273,7 @@
 
     f = _PyObject_LookupSpecial(op, &PyId___complex__);
     if (f) {
-        PyObject *res = PyObject_CallFunctionObjArgs(f, NULL);
+        PyObject *res = _PyObject_CallNoArg(f);
         Py_DECREF(f);
         if (res != NULL && !PyComplex_Check(res)) {
             PyErr_SetString(PyExc_TypeError,
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1414,7 +1414,7 @@
         return -1;
     }
     if (value == NULL)
-        res = PyObject_CallFunctionObjArgs(func, obj, NULL);
+        res = _PyObject_CallArg1(func, obj);
     else
         res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
     if (res == NULL)
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2066,8 +2066,7 @@
             _Py_IDENTIFIER(__missing__);
             missing = _PyObject_LookupSpecial((PyObject *)mp, &PyId___missing__);
             if (missing != NULL) {
-                res = PyObject_CallFunctionObjArgs(missing,
-                                                   key, NULL);
+                res = _PyObject_CallArg1(missing, key);
                 Py_DECREF(missing);
                 return res;
             }
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
--- a/Objects/enumobject.c
+++ b/Objects/enumobject.c
@@ -258,7 +258,7 @@
         return NULL;
     }
     if (reversed_meth != NULL) {
-        PyObject *res = PyObject_CallFunctionObjArgs(reversed_meth, NULL);
+        PyObject *res = _PyObject_CallNoArg(reversed_meth);
         Py_DECREF(reversed_meth);
         return res;
     }
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1439,7 +1439,7 @@
         goto parse_error;
     result = PyFloat_FromDouble(negate ? -x : x);
     if (cls != (PyObject *)&PyFloat_Type && result != NULL) {
-        Py_SETREF(result, PyObject_CallFunctionObjArgs(cls, result, NULL));
+        Py_SETREF(result, _PyObject_CallArg1(cls, result));
     }
     return result;
 
diff --git a/Objects/genobject.c b/Objects/genobject.c
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -43,7 +43,7 @@
             /* Save the current exception, if any. */
             PyErr_Fetch(&error_type, &error_value, &error_traceback);
 
-            res = PyObject_CallFunctionObjArgs(finalizer, self, NULL);
+            res = _PyObject_CallArg1(finalizer, self);
 
             if (res == NULL) {
                 PyErr_WriteUnraisable(self);
@@ -591,7 +591,7 @@
      *
      * (See PyErr_SetObject/_PyErr_CreateException code for details.)
      */
-    e = PyObject_CallFunctionObjArgs(PyExc_StopIteration, value, NULL);
+    e = _PyObject_CallArg1(PyExc_StopIteration, value);
     if (e == NULL) {
         return -1;
     }
diff --git a/Objects/listobject.c b/Objects/listobject.c
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1970,8 +1970,7 @@
         }
 
         for (i = 0; i < saved_ob_size ; i++) {
-            keys[i] = PyObject_CallFunctionObjArgs(keyfunc, saved_ob_item[i],
-                                                   NULL);
+            keys[i] = _PyObject_CallArg1(keyfunc, saved_ob_item[i]);
             if (keys[i] == NULL) {
                 for (i=i-1 ; i>=0 ; i--)
                     Py_DECREF(keys[i]);
diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -5282,8 +5282,7 @@
     Py_DECREF(bytes);
 
     if (type != &PyLong_Type) {
-        Py_SETREF(long_obj, PyObject_CallFunctionObjArgs((PyObject *)type,
-                                                         long_obj, NULL));
+        Py_SETREF(long_obj, _PyObject_CallArg1((PyObject *)type, long_obj));
     }
 
     return long_obj;
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -1939,7 +1939,7 @@
     if (format == NULL)
         goto error;
 
-    structobj = PyObject_CallFunctionObjArgs(Struct, format, NULL);
+    structobj = _PyObject_CallArg1(Struct, format);
     if (structobj == NULL)
         goto error;
 
@@ -1978,7 +1978,7 @@
     PyObject *v;
 
     memcpy(x->item, ptr, x->itemsize);
-    v = PyObject_CallFunctionObjArgs(x->unpack_from, x->mview, NULL);
+    v = _PyObject_CallArg1(x->unpack_from, x->mview);
     if (v == NULL)
         return NULL;
 
diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -596,7 +596,7 @@
 
     func = _PyObject_LookupSpecial(v, &PyId___bytes__);
     if (func != NULL) {
-        result = PyObject_CallFunctionObjArgs(func, NULL);
+        result = _PyObject_CallNoArg(func);
         Py_DECREF(func);
         if (result == NULL)
             return NULL;
@@ -1314,7 +1314,7 @@
         return NULL;
     }
     /* use __dir__ */
-    result = PyObject_CallFunctionObjArgs(dirfunc, NULL);
+    result = _PyObject_CallNoArg(dirfunc);
     Py_DECREF(dirfunc);
     if (result == NULL)
         return NULL;
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -1256,7 +1256,7 @@
     if (PyODict_CheckExact(od))
         od_copy = PyODict_New();
     else
-        od_copy = PyObject_CallFunctionObjArgs((PyObject *)Py_TYPE(od), NULL);
+        od_copy = _PyObject_CallNoArg((PyObject *)Py_TYPE(od));
     if (od_copy == NULL)
         return NULL;
 
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3487,9 +3487,7 @@
         sorted = _PyDict_GetItemId(builtins, &PyId_sorted);
         if (sorted == NULL)
             goto error;
-        sorted_methods = PyObject_CallFunctionObjArgs(sorted,
-                                                      abstract_methods,
-                                                      NULL);
+        sorted_methods = _PyObject_CallArg1(sorted, abstract_methods);
         if (sorted_methods == NULL)
             goto error;
         comma = _PyUnicode_FromId(&comma_id);
@@ -6193,7 +6191,7 @@
         else
             attr = descr;
     }
-    res = PyObject_CallFunctionObjArgs(attr, name, NULL);
+    res = _PyObject_CallArg1(attr, name);
     Py_XDECREF(descr);
     return res;
 }
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -4269,7 +4269,7 @@
     if (*exceptionObject == NULL)
         goto onError;
 
-    restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL);
+    restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
     if (restuple == NULL)
         goto onError;
     if (!PyTuple_Check(restuple)) {
@@ -4368,7 +4368,7 @@
     if (*exceptionObject == NULL)
         goto onError;
 
-    restuple = PyObject_CallFunctionObjArgs(*errorHandler, *exceptionObject, NULL);
+    restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
     if (restuple == NULL)
         goto onError;
     if (!PyTuple_Check(restuple)) {
@@ -6649,8 +6649,7 @@
     if (*exceptionObject == NULL)
         return NULL;
 
-    restuple = PyObject_CallFunctionObjArgs(
-        *errorHandler, *exceptionObject, NULL);
+    restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
     if (restuple == NULL)
         return NULL;
     if (!PyTuple_Check(restuple)) {
@@ -8644,8 +8643,7 @@
     if (*exceptionObject == NULL)
         return NULL;
 
-    restuple = PyObject_CallFunctionObjArgs(
-        *errorHandler, *exceptionObject, NULL);
+    restuple = _PyObject_CallArg1(*errorHandler, *exceptionObject);
     if (restuple == NULL)
         return NULL;
     if (!PyTuple_Check(restuple)) {
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -867,7 +867,7 @@
 static void
 handle_callback(PyWeakReference *ref, PyObject *callback)
 {
-    PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL);
+    PyObject *cbresult = _PyObject_CallArg1(callback, ref);
 
     if (cbresult == NULL)
         PyErr_WriteUnraisable(callback);
diff --git a/Python/_warnings.c b/Python/_warnings.c
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -415,7 +415,7 @@
     if (msg == NULL)
         goto error;
 
-    res = PyObject_CallFunctionObjArgs(show_fn, msg, NULL);
+    res = _PyObject_CallArg1(show_fn, msg);
     Py_DECREF(show_fn);
     Py_DECREF(msg);
 
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -469,7 +469,7 @@
             ok = PyObject_IsTrue(item);
         } else {
             PyObject *good;
-            good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
+            good = _PyObject_CallArg1(lz->func, item);
             if (good == NULL) {
                 Py_DECREF(item);
                 return NULL;
@@ -1519,7 +1519,7 @@
     while (( item = PyIter_Next(it) )) {
         /* get the value from the key function */
         if (keyfunc != NULL) {
-            val = PyObject_CallFunctionObjArgs(keyfunc, item, NULL);
+            val = _PyObject_CallArg1(keyfunc, item);
             if (val == NULL)
                 goto Fail_it_item;
         }
@@ -2044,9 +2044,9 @@
     }
 
     if (ndigits == NULL || ndigits == Py_None)
-        result = PyObject_CallFunctionObjArgs(round, NULL);
+        result = _PyObject_CallNoArg(round);
     else
-        result = PyObject_CallFunctionObjArgs(round, ndigits, NULL);
+        result = _PyObject_CallArg1(round, ndigits);
     Py_DECREF(round);
     return result;
 }
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1756,7 +1756,7 @@
                 Py_DECREF(value);
                 goto error;
             }
-            res = PyObject_CallFunctionObjArgs(hook, value, NULL);
+            res = _PyObject_CallArg1(hook, value);
             Py_DECREF(value);
             if (res == NULL)
                 goto error;
@@ -3062,7 +3062,7 @@
             Py_DECREF(mgr);
             if (enter == NULL)
                 goto error;
-            res = PyObject_CallFunctionObjArgs(enter, NULL);
+            res = _PyObject_CallNoArg(enter);
             Py_DECREF(enter);
             if (res == NULL)
                 goto error;
@@ -3096,7 +3096,7 @@
             }
             SET_TOP(exit);
             Py_DECREF(mgr);
-            res = PyObject_CallFunctionObjArgs(enter, NULL);
+            res = _PyObject_CallNoArg(enter);
             Py_DECREF(enter);
             if (res == NULL)
                 goto error;
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -985,7 +985,7 @@
         PyObject *hook = PyList_GetItem(path_hooks, j);
         if (hook == NULL)
             return NULL;
-        importer = PyObject_CallFunctionObjArgs(hook, p, NULL);
+        importer = _PyObject_CallArg1(hook, p);
         if (importer != NULL)
             break;
 
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1098,7 +1098,7 @@
                          Py_TYPE(o)->tp_name);
     }
     else {
-        res = PyObject_CallFunctionObjArgs(method, NULL);
+        res = _PyObject_CallNoArg(method);
         Py_DECREF(method);
     }
 

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


More information about the Python-checkins mailing list