summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorstratakis <cstratak@redhat.com>2017-11-02 10:32:54 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2017-11-02 10:32:54 (GMT)
commite8b19656396381407ad91473af5da8b0d4346e88 (patch)
tree16638970d5014728a49808d0c80c4af0fe6ccb91 /Objects/tupleobject.c
parent4f469c096628af730b17798d0ebfd8925bfde836 (diff)
downloadcpython-e8b19656396381407ad91473af5da8b0d4346e88.zip
cpython-e8b19656396381407ad91473af5da8b0d4346e88.tar.gz
cpython-e8b19656396381407ad91473af5da8b0d4346e88.tar.bz2
bpo-23699: Use a macro to reduce boilerplate code in rich comparison functions (GH-793)
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index c150af8..35decd8 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -647,23 +647,7 @@ tuplerichcompare(PyObject *v, PyObject *w, int op)
if (i >= vlen || i >= wlen) {
/* No more items to compare -- compare sizes */
- int cmp;
- PyObject *res;
- switch (op) {
- case Py_LT: cmp = vlen < wlen; break;
- case Py_LE: cmp = vlen <= wlen; break;
- case Py_EQ: cmp = vlen == wlen; break;
- case Py_NE: cmp = vlen != wlen; break;
- case Py_GT: cmp = vlen > wlen; break;
- case Py_GE: cmp = vlen >= wlen; break;
- default: return NULL; /* cannot happen */
- }
- if (cmp)
- res = Py_True;
- else
- res = Py_False;
- Py_INCREF(res);
- return res;
+ Py_RETURN_RICHCOMPARE(vlen, wlen, op);
}
/* We have an item that differs -- shortcuts for EQ/NE */