Skip to content

Commit

Permalink
Add identity shortcut to PyObject_RichCompareBool.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger committed Mar 21, 2004
1 parent 07973da commit 93d4481
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,19 @@ PyObject_RichCompare(PyObject *v, PyObject *w, int op)
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))
Expand Down

0 comments on commit 93d4481

Please sign in to comment.