From 81912d4764eb8ccb1b069de46c7f78381f4b19a6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sat, 24 Aug 2002 05:33:28 +0000 Subject: Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost always returns a bool, so avoid calling PyObject_IsTrue() in that case. --- Objects/object.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Objects/object.c b/Objects/object.c index 04a7c1f..1283294 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; } -- cgit v0.12