summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-09-03 20:39:51 (GMT)
committerGuido van Rossum <guido@python.org>1992-09-03 20:39:51 (GMT)
commitebc8c51cde0432b5c70079f5fa05295224e8cb78 (patch)
treeb4519db51c25d11631b72a2e831336fc1a4f8b02 /Objects/classobject.c
parentaa7ca2dc1a50e379a8173e13edb0a640c5402276 (diff)
downloadcpython-ebc8c51cde0432b5c70079f5fa05295224e8cb78.zip
cpython-ebc8c51cde0432b5c70079f5fa05295224e8cb78.tar.gz
cpython-ebc8c51cde0432b5c70079f5fa05295224e8cb78.tar.bz2
Compare instance methods by comparing the object and the function.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index d4a2f82..19f887c 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -828,6 +828,16 @@ instancemethod_dealloc(im)
free((ANY *)im);
}
+static int
+instancemethod_compare(a, b)
+ instancemethodobject *a, *b;
+{
+ int cmp = cmpobject(a->im_self, b->im_self);
+ if (cmp == 0)
+ cmp = cmpobject(a->im_func, b->im_func);
+ return cmp;
+}
+
typeobject Instancemethodtype = {
OB_HEAD_INIT(&Typetype)
0,
@@ -838,7 +848,7 @@ typeobject Instancemethodtype = {
0, /*tp_print*/
instancemethod_getattr, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ instancemethod_compare, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/