diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-10-17 20:54:53 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-10-17 20:54:53 +0000 |
commit | 8f67d0893f7170986b0ad370844318544270cbcc (patch) | |
tree | 4aec6cf093d4d042d18d1fadc3ce52765d32bd8d /Objects/object.c | |
parent | 6fb457526cef485d64f4f6744d81cae8c02032b3 (diff) | |
download | cpython-git-8f67d0893f7170986b0ad370844318544270cbcc.tar.gz |
make hashes always the size of pointers; introduce Py_hash_t #9778
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Objects/object.c b/Objects/object.c index ff3363f432..2f544ba67e 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -687,7 +687,7 @@ PyObject_RichCompareBool(PyObject *v, PyObject *w, int op) */ -long +Py_hash_t _Py_HashDouble(double v) { int e, sign; @@ -730,24 +730,24 @@ _Py_HashDouble(double v) x = x * sign; if (x == (unsigned long)-1) x = (unsigned long)-2; - return (long)x; + return (Py_hash_t)x; } -long +Py_hash_t _Py_HashPointer(void *p) { - long x; + Py_hash_t x; size_t y = (size_t)p; /* bottom 3 or 4 bits are likely to be 0; rotate y by 4 to avoid excessive hash collisions for dicts and sets */ y = (y >> 4) | (y << (8 * SIZEOF_VOID_P - 4)); - x = (long)y; + x = (Py_hash_t)y; if (x == -1) x = -2; return x; } -long +Py_hash_t PyObject_HashNotImplemented(PyObject *v) { PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'", @@ -755,7 +755,7 @@ PyObject_HashNotImplemented(PyObject *v) return -1; } -long +Py_hash_t PyObject_Hash(PyObject *v) { PyTypeObject *tp = Py_TYPE(v); |