mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Add identity shortcut to PyObject_RichCompareBool.
This commit is contained in:
parent
07973dab97
commit
93d448198b
1 changed files with 11 additions and 1 deletions
|
@ -871,9 +871,19 @@ Done:
|
|||
int
|
||||
PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
|
||||
{
|
||||
PyObject *res = PyObject_RichCompare(v, w, op);
|
||||
PyObject *res;
|
||||
int ok;
|
||||
|
||||
/* Quick result when objects are the same.
|
||||
Guarantees that identity implies equality. */
|
||||
if (v == w) {
|
||||
if (op == Py_EQ)
|
||||
return 1;
|
||||
else if (op == Py_NE)
|
||||
return 0;
|
||||
}
|
||||
|
||||
res = PyObject_RichCompare(v, w, op);
|
||||
if (res == NULL)
|
||||
return -1;
|
||||
if (PyBool_Check(res))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue