mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost
always returns a bool, so avoid calling PyObject_IsTrue() in that case.
This commit is contained in:
parent
d50185127f
commit
81912d4764
1 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue