diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-21 19:46:33 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-21 19:46:33 (GMT) |
commit | ce4a9da70535b4bb9048147b141f01004af2133d (patch) | |
tree | 853fa7484683a9c858f29bfab1320fb4baee5d98 /Objects/object.c | |
parent | 0a3229de6b80cfa9e432ef5a9c72548569503075 (diff) | |
download | cpython-ce4a9da70535b4bb9048147b141f01004af2133d.zip cpython-ce4a9da70535b4bb9048147b141f01004af2133d.tar.gz cpython-ce4a9da70535b4bb9048147b141f01004af2133d.tar.bz2 |
Issue #13411: memoryview objects are now hashable when the underlying object is hashable.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index 25e64e1..00f1716 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -744,6 +744,21 @@ _Py_HashPointer(void *p) } Py_hash_t +_Py_HashBytes(unsigned char *p, Py_ssize_t len) +{ + Py_uhash_t x; + Py_ssize_t i; + + x = (Py_uhash_t) *p << 7; + for (i = 0; i < len; i++) + x = (1000003U * x) ^ (Py_uhash_t) *p++; + x ^= (Py_uhash_t) len; + if (x == -1) + x = -2; + return x; +} + +Py_hash_t PyObject_HashNotImplemented(PyObject *v) { PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'", |