Issue #6970: Remove redundant calls made when comparing objects.
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 @@
 {
 	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 @@
 			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;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 24866ff..be4b6f8 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5068,7 +5068,7 @@
 };
 
 static PyObject *
-half_richcompare(PyObject *self, PyObject *other, int op)
+slot_tp_richcompare(PyObject *self, PyObject *other, int op)
 {
 	PyObject *func, *args, *res;
 	static PyObject *op_str[6];
@@ -5091,28 +5091,6 @@
 }
 
 static PyObject *
-slot_tp_richcompare(PyObject *self, PyObject *other, int op)
-{
-	PyObject *res;
-
-	if (Py_TYPE(self)->tp_richcompare == slot_tp_richcompare) {
-		res = half_richcompare(self, other, op);
-		if (res != Py_NotImplemented)
-			return res;
-		Py_DECREF(res);
-	}
-	if (Py_TYPE(other)->tp_richcompare == slot_tp_richcompare) {
-		res = half_richcompare(other, self, _Py_SwappedOp[op]);
-		if (res != Py_NotImplemented) {
-			return res;
-		}
-		Py_DECREF(res);
-	}
-	Py_INCREF(Py_NotImplemented);
-	return Py_NotImplemented;
-}
-
-static PyObject *
 slot_tp_iter(PyObject *self)
 {
 	PyObject *func, *res;