mp.c: Factor out and export `mphash'.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 15 Oct 2019 10:48:12 +0000 (11:48 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 17 Nov 2019 02:50:40 +0000 (02:50 +0000)
catacomb-python.h
mp.c

index 0307701..490862b 100644 (file)
@@ -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 (file)
--- 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;