From be6df1c38491ef517f2f55f2abc9c9e64ea034b0 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Tue, 15 Oct 2019 11:48:12 +0100 Subject: [PATCH] mp.c: Factor out and export `mphash'. Organization: Straylight/Edgeware From: Mark Wooding --- catacomb-python.h | 1 + mp.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/catacomb-python.h b/catacomb-python.h index 0307701..490862b 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -324,6 +324,7 @@ extern mp *getgf(PyObject *); extern int convgf(PyObject *, void *); extern PyObject *mp_pywrap(mp *); extern PyObject *gf_pywrap(mp *); +extern long mphash(mp *); extern mp *mp_frompyobject(PyObject *, int); extern PyObject *mp_topystring(mp *, int, const char *, const char *, const char *); diff --git a/mp.c b/mp.c index 88ee738..9330121 100644 --- a/mp.c +++ b/mp.c @@ -544,13 +544,15 @@ end: return ((PyObject *)zz); } -static long mp_pyhash(PyObject *me) +long mphash(mp *x) { - long h; - PyObject *l = mp_topylong(MP_X(me)); h = PyObject_Hash(l); + PyObject *l = mp_topylong(x); + long h = PyObject_Hash(l); Py_DECREF(l); return (h); } +static long mp_pyhash(PyObject *me) { return (mphash(MP_X(me))); } + static PyObject *mpmeth_jacobi(PyObject *me, PyObject *arg) { mp *y = 0; -- [mdw]