]> granicus.if.org Git - python/commitdiff
Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost
authorGuido van Rossum <guido@python.org>
Sat, 24 Aug 2002 05:33:28 +0000 (05:33 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 24 Aug 2002 05:33:28 +0000 (05:33 +0000)
always returns a bool, so avoid calling PyObject_IsTrue() in that
case.

Objects/object.c

index 04a7c1f09bb095d5cf395bebec56f11d4fd7eb83..1283294a060e5d817974afab19f66bf081e160b7 100644 (file)
@@ -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;
 }