Index: Objects/object.c =================================================================== --- Objects/object.c (révision 69444) +++ Objects/object.c (copie de travail) @@ -1073,7 +1073,23 @@ _Py_HashPointer(void *p) { #if SIZEOF_LONG >= SIZEOF_VOID_P - return (long)p; + unsigned long x = (unsigned long) p; + /* bottom 4 bits are likely to be 0, or at least non-significant; + shift the remaining bits to the right so as to avoid excessive + hash collisions for dicts and sets */ + x = (x >> 4) + (x << (8*SIZEOF_LONG - 4)); + if (x == (unsigned long) -1) + x = -2; + return x; +/* 64-bit Windows has sizeof(long) == 4 and sizeof(void *) == 8 */ +#elif SIZEOF_VOID_P == SIZEOF_LONG*2 + size_t y = (size_t)p; + unsigned long x; + x = (unsigned long) (y >> 8*SIZEOF_LONG) + (unsigned long) (y >> 4) + + (unsigned long) (y << (8*SIZEOF_LONG - 4)); + if (x == (unsigned long) -1) + x = -2; + return x; #else /* convert to a Python long and hash that */ PyObject* longobj;