From 20a3007a8de57c99713cae8849634f47689a8f19 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 19 Aug 2016 18:28:25 +0200 Subject: [PATCH] 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. --- Objects/typeobject.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 46f944c8046..4d259275b4e 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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; }