summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-11-15 13:58:49 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-11-15 13:58:49 (GMT)
commit6f1d04945b98cd66b95131833942526c85bbb867 (patch)
tree7c6bdef12d242b18389d4c46e6c984aadadf3b98 /Objects/object.c
parentf4243f6d1f1a7512751d26235a492c24a9a4c76c (diff)
downloadcpython-6f1d04945b98cd66b95131833942526c85bbb867.zip
cpython-6f1d04945b98cd66b95131833942526c85bbb867.tar.gz
cpython-6f1d04945b98cd66b95131833942526c85bbb867.tar.bz2
Issue #6970: Remove redundant calls made when comparing objects.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 90cdc74..002acd0 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -544,10 +544,12 @@ do_richcompare(PyObject *v, PyObject *w, int op)
{
richcmpfunc f;
PyObject *res;
+ int checked_reverse_op = 0;
if (v->ob_type != w->ob_type &&
PyType_IsSubtype(w->ob_type, v->ob_type) &&
(f = w->ob_type->tp_richcompare) != NULL) {
+ checked_reverse_op = 1;
res = (*f)(w, v, _Py_SwappedOp[op]);
if (res != Py_NotImplemented)
return res;
@@ -559,7 +561,7 @@ do_richcompare(PyObject *v, PyObject *w, int op)
return res;
Py_DECREF(res);
}
- if ((f = w->ob_type->tp_richcompare) != NULL) {
+ if (!checked_reverse_op && (f = w->ob_type->tp_richcompare) != NULL) {
res = (*f)(w, v, _Py_SwappedOp[op]);
if (res != Py_NotImplemented)
return res;