summaryrefslogtreecommitdiffstats
path: root/Objects
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
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')
-rw-r--r--Objects/object.c4
-rw-r--r--Objects/typeobject.c24
2 files changed, 4 insertions, 24 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;
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 char *name_op[] = {
};
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 @@ half_richcompare(PyObject *self, PyObject *other, int op)
}
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;