From 85bc8b4f2fadf63ead76af4ec6114f78ffd7286f Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 22 Oct 2019 17:53:44 +0100 Subject: [PATCH] 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. --- ec.c | 8 ++++---- field.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ec.c b/ec.c index e5fd254..a77a91e 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@ */ -- 2.11.0