chiark
/
gitweb
/
~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mp.c: Describe `MP' and `GF' conversion semantics.
[catacomb-python]
/
mp.c
diff --git
a/mp.c
b/mp.c
index 88ee73813b538baa863097df8f07232a4fe66523..62d2dfeee29a7d6323128ab2317b1303a8742ee6 100644
(file)
--- a/
mp.c
+++ b/
mp.c
@@
-544,13
+544,15
@@
end:
return ((PyObject *)zz);
}
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);
}
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;
static PyObject *mpmeth_jacobi(PyObject *me, PyObject *arg)
{
mp *y = 0;
@@
-890,11
+892,15
@@
static PyTypeObject mp_pytype_skel = {
/* @tp_doc@ */
"Multiprecision integers, similar to `long' but more efficient and\n\
/* @tp_doc@ */
"Multiprecision integers, similar to `long' but more efficient and\n\
-versatile. Support all the standard arithmetic operations.\n\
+versatile. Support all the standard arithmetic operations, with\n\
+implicit conversions from `PrimeFilter', and other objects which\n\
+convert to `long'.\n\
\n\
\n\
-Constructor
mp(X, radix = R) attempts to convert X to an `mp
'. If\n\
+Constructor
MP(X, radix = R) attempts to convert X to an `MP
'. If\n\
X is a string, it's read in radix-R form, or we look for a prefix\n\
X is a string, it's read in radix-R form, or we look for a prefix\n\
-if R = 0. Other acceptable things are ints and longs.\n\
+if R = 0. Other acceptable things are field elements, elliptic curve\n\
+points, group elements, Python `int' and `long' objects, and anything\n\
+with an integer conversion.\n\
\n\
Notes:\n\
\n\
\n\
Notes:\n\
\n\
@@
-1885,15
+1891,6
@@
end:
return ((PyObject *)zz);
}
return ((PyObject *)zz);
}
-static long gf_pyhash(PyObject *me)
-{
- long i = mp_tolong(MP_X(me));
- i ^= 0xc7ecd67c; /* random perturbance */
- if (i == -1)
- i = -2;
- return (i);
-}
-
static PyObject *gf_pyexp(PyObject *x, PyObject *y, PyObject *z)
{
mp *xx = 0, *yy = 0, *zz = 0;
static PyObject *gf_pyexp(PyObject *x, PyObject *y, PyObject *z)
{
mp *xx = 0, *yy = 0, *zz = 0;
@@
-2076,7
+2073,7
@@
static PyTypeObject gf_pytype_skel = {
&gf_pynumber, /* @tp_as_number@ */
0, /* @tp_as_sequence@ */
0, /* @tp_as_mapping@ */
&gf_pynumber, /* @tp_as_number@ */
0, /* @tp_as_sequence@ */
0, /* @tp_as_mapping@ */
-
gf
_pyhash, /* @tp_hash@ */
+
mp
_pyhash, /* @tp_hash@ */
0, /* @tp_call@ */
mp_pyhex, /* @tp_str@ */
0, /* @tp_getattro@ */
0, /* @tp_call@ */
mp_pyhex, /* @tp_str@ */
0, /* @tp_getattro@ */
@@
-2090,9
+2087,11
@@
static PyTypeObject gf_pytype_skel = {
"Binary polynomials. Support almost all the standard arithmetic\n\
operations.\n\
\n\
"Binary polynomials. Support almost all the standard arithmetic\n\
operations.\n\
\n\
-Constructor
gf(X, radix = R) attempts to convert X to a `gf
'. If\n\
+Constructor
GF(X, radix = R) attempts to convert X to a `GF
'. If\n\
X is a string, it's read in radix-R form, or we look for a prefix\n\
X is a string, it's read in radix-R form, or we look for a prefix\n\
-if R = 0. Other acceptable things are ints and longs.\n\
+if R = 0. Other acceptable things are field elements, elliptic curve\n\
+points, group elements, Python `int' and `long' objects, and anything\n\
+with an integer conversion.\n\
\n\
The name is hopelessly wrong from a technical point of view, but\n\
but it's much easier to type than `p2' or `c2' or whatever.\n\
\n\
The name is hopelessly wrong from a technical point of view, but\n\
but it's much easier to type than `p2' or `c2' or whatever.\n\