mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +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)
|
if (res == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
ok = PyObject_IsTrue(res);
|
if (PyBool_Check(res))
|
||||||
|
ok = (res == Py_True);
|
||||||
|
else
|
||||||
|
ok = PyObject_IsTrue(res);
|
||||||
Py_DECREF(res);
|
Py_DECREF(res);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue