diff options
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index cdbceaf..2c43221 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -687,6 +687,15 @@ PyObject_RichCompareBool(PyObject *v, PyObject *w, int 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; |