summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index b913a06..bda27e0 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -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))