X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/c461c9b380b56a41399e5f540e4bb97cfd9ceffe..dc0757504af5097a4bb323d64e429a99f86d1076:/field.c diff --git a/field.c b/field.c index a18a942..cce2e89 100644 --- a/field.c +++ b/field.c @@ -66,7 +66,7 @@ static PyObject *field_dopywrap(PyTypeObject *ty, field *f) fobj->ty.ht_type.tp_alloc = PyType_GenericAlloc; fobj->ty.ht_type.tp_free = 0; fobj->ty.ht_type.tp_new = fe_pynew; - PyType_Ready(&fobj->ty.ht_type); + typeready(&fobj->ty.ht_type); return ((PyObject *)fobj); } @@ -230,11 +230,13 @@ end: static long fe_pyhash(PyObject *me) { - long i = mp_tolong(FE_X(me)); - i ^= 0xdcf62d6c; /* random perturbance */ - if (i == -1) - i = -2; - return (i); + size_t sz = FE_F(me)->noctets; + uint32 h = 0xe0c127ca + FE_F(me)->ops->ty; + octet *p = xmalloc(sz); + mp_storeb(FE_X(me), p, sz); + h = unihash_hash(&unihash_global, h, p, sz); + xfree(p); + return (h % LONG_MAX); } static int fe_pycoerce(PyObject **x, PyObject **y)