Add identity shortcut to PyObject_RichCompareBool.
This commit is contained in:
parent
07973dab97
commit
93d448198b
|
@ -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…
Reference in New Issue