From: Mark Wooding Date: Tue, 22 Oct 2019 16:53:44 +0000 (+0100) Subject: ec.c, field.c: Remove redundant `FOO_pyrichcompare' methods. X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/commitdiff_plain/e6ed58c71b526c8dbb471484d95bb467cddf89d4 ec.c, field.c: Remove redundant `FOO_pyrichcompare' methods. The abstract base classes already have the necessary comparison methods, so there's nothing to be gained by repeating the same methods on subclasses. (Indeed, Python might pointlessly allocate more memory for the corresponding Python-level descriptors, but I haven't checked.) But there is something to be lost: Python 3 explicitly clobbers the `__hash__' methods of subclasses which declare new equality methods. We could add duplicates of the hash methods throughout the subclass graph, but it seems better to delete the pointless equality methods which are causing the problem. --- diff --git a/ec.c b/ec.c index c9707b7..d631a91 100644 --- a/ec.c +++ b/ec.c @@ -1147,7 +1147,7 @@ static const PyTypeObject ecprimecurve_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - eccurve_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ @@ -1202,7 +1202,7 @@ static const PyTypeObject ecprimeprojcurve_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - eccurve_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ @@ -1257,7 +1257,7 @@ static const PyTypeObject ecbincurve_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - eccurve_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ @@ -1312,7 +1312,7 @@ static const PyTypeObject ecbinprojcurve_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - eccurve_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ diff --git a/field.c b/field.c index fa424df..5f3b58c 100644 --- a/field.c +++ b/field.c @@ -646,7 +646,7 @@ static const PyTypeObject primefield_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - field_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ @@ -713,7 +713,7 @@ static const PyTypeObject niceprimefield_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - field_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ @@ -777,7 +777,7 @@ static const PyTypeObject binfield_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - field_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ @@ -843,7 +843,7 @@ static const PyTypeObject binpolyfield_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - field_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ @@ -922,7 +922,7 @@ static const PyTypeObject binnormfield_pytype_skel = { 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ - field_pyrichcompare, /* @tp_richcompare@ */ + 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */