Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost

always returns a bool, so avoid calling PyObject_IsTrue() in that
case.
This commit is contained in:
Guido van Rossum 2002-08-24 05:33:28 +00:00
parent d50185127f
commit 81912d4764

View 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;
}