From: Guido van Rossum Date: Sat, 24 Aug 2002 05:33:28 +0000 (+0000) Subject: Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost X-Git-Tag: v2.3c1~4309 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81912d4764eb8ccb1b069de46c7f78381f4b19a6;p=python Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost always returns a bool, so avoid calling PyObject_IsTrue() in that case. --- diff --git a/Objects/object.c b/Objects/object.c index 04a7c1f09b..1283294a06 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -998,7 +998,10 @@ PyObject_RichCompareBool(PyObject *v, PyObject *w, int op) if (res == NULL) return -1; - ok = PyObject_IsTrue(res); + if (PyBool_Check(res)) + ok = (res == Py_True); + else + ok = PyObject_IsTrue(res); Py_DECREF(res); return ok; }