mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Issue #13411: memoryview objects are now hashable when the underlying object is hashable.
This commit is contained in:
parent
0a3229de6b
commit
ce4a9da705
9 changed files with 100 additions and 19 deletions
|
|
@ -743,6 +743,21 @@ _Py_HashPointer(void *p)
|
|||
return x;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue