make hashes always the size of pointers; introduce Py_hash_t #9778

This commit is contained in:
Benjamin Peterson 2010-10-17 20:54:53 +00:00
parent 6fb457526c
commit 8f67d0893f
31 changed files with 137 additions and 131 deletions

View file

@ -1148,12 +1148,12 @@ Delete a named attribute on an object; delattr(x, 'y') is equivalent to\n\
static PyObject *
builtin_hash(PyObject *self, PyObject *v)
{
long x;
Py_hash_t x;
x = PyObject_Hash(v);
if (x == -1)
return NULL;
return PyLong_FromLong(x);
return PyLong_FromSsize_t(x);
}
PyDoc_STRVAR(hash_doc,

View file

@ -2102,7 +2102,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
/* Inline the PyDict_GetItem() calls.
WARNING: this is an extreme speed hack.
Do not try this at home. */
long hash = ((PyUnicodeObject *)w)->hash;
Py_hash_t hash = ((PyUnicodeObject *)w)->hash;
if (hash != -1) {
PyDictObject *d;
PyDictEntry *e;

View file

@ -567,7 +567,7 @@ get_hash_info(void)
if (hash_info == NULL)
return NULL;
PyStructSequence_SET_ITEM(hash_info, field++,
PyLong_FromLong(8*sizeof(long)));
PyLong_FromLong(8*sizeof(Py_hash_t)));
PyStructSequence_SET_ITEM(hash_info, field++,
PyLong_FromLong(_PyHASH_MODULUS));
PyStructSequence_SET_ITEM(hash_info, field++,