[Python-checkins] cpython: slot_nb_bool() now uses fast call

victor.stinner python-checkins at python.org
Fri Aug 19 12:53:54 EDT 2016


https://hg.python.org/cpython/rev/6a21b6599692
changeset:   102777:6a21b6599692
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Aug 19 18:28:25 2016 +0200
summary:
  slot_nb_bool() now uses fast call

Issue #27128: slot_nb_bool() now calls _PyObject_FastCall() to avoid a
temporary empty tuple to call the slot function.

files:
  Objects/typeobject.c |  10 ++--------
  1 files changed, 2 insertions(+), 8 deletions(-)


diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5946,7 +5946,7 @@
 static int
 slot_nb_bool(PyObject *self)
 {
-    PyObject *func, *args, *value;
+    PyObject *func, *value;
     int result;
     int using_len = 0;
     _Py_IDENTIFIER(__bool__);
@@ -5967,13 +5967,7 @@
         using_len = 1;
     }
 
-    args = PyTuple_New(0);
-    if (args == NULL) {
-        goto error;
-    }
-
-    value = PyObject_Call(func, args, NULL);
-    Py_DECREF(args);
+    value = _PyObject_FastCall(func, NULL, 0, NULL);
     if (value == NULL) {
         goto error;
     }

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


More information about the Python-checkins mailing list