]> granicus.if.org Git - python/commitdiff
slot_nb_bool() now uses fast call
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 16:28:25 +0000 (18:28 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 16:28:25 +0000 (18:28 +0200)
Issue #27128: slot_nb_bool() now calls _PyObject_FastCall() to avoid a
temporary empty tuple to call the slot function.

Objects/typeobject.c

index 46f944c8046f160f270037e47fd52c5709b7e3de..4d259275b4e5a6cc6a32c5cf504cb904bcdb8dc5 100644 (file)
@@ -5946,7 +5946,7 @@ SLOT0(slot_nb_absolute, "__abs__")
 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 @@ slot_nb_bool(PyObject *self)
         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;
     }