mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +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
|
int
|
||||||
PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
|
PyObject_RichCompareBool(PyObject *v, PyObject *w, int op)
|
||||||
{
|
{
|
||||||
PyObject *res = PyObject_RichCompare(v, w, op);
|
PyObject *res;
|
||||||
int ok;
|
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)
|
if (res == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if (PyBool_Check(res))
|
if (PyBool_Check(res))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue