@@ -301,23 +301,8 @@ tuple_repr(PyObject *self)
301301 For the xxHash specification, see
302302 https://github.com/Cyan4973/xxHash/blob/master/doc/xxhash_spec.md
303303
304- Below are the official constants from the xxHash specification. Optimizing
305- compilers should emit a single "rotate" instruction for the
306- _PyHASH_XXROTATE() expansion. If that doesn't happen for some important
307- platform, the macro could be changed to expand to a platform-specific rotate
308- spelling instead.
304+ The constants for the hard function are defined in pycore_tuple.h.
309305*/
310- #if SIZEOF_PY_UHASH_T > 4
311- #define _PyHASH_XXPRIME_1 ((Py_uhash_t)11400714785074694791ULL)
312- #define _PyHASH_XXPRIME_2 ((Py_uhash_t)14029467366897019727ULL)
313- #define _PyHASH_XXPRIME_5 ((Py_uhash_t)2870177450012600261ULL)
314- #define _PyHASH_XXROTATE (x ) ((x << 31) | (x >> 33)) /* Rotate left 31 bits */
315- #else
316- #define _PyHASH_XXPRIME_1 ((Py_uhash_t)2654435761UL)
317- #define _PyHASH_XXPRIME_2 ((Py_uhash_t)2246822519UL)
318- #define _PyHASH_XXPRIME_5 ((Py_uhash_t)374761393UL)
319- #define _PyHASH_XXROTATE (x ) ((x << 13) | (x >> 19)) /* Rotate left 13 bits */
320- #endif
321306
322307static Py_hash_t
323308tuple_hash (PyObject * op )
@@ -330,19 +315,19 @@ tuple_hash(PyObject *op)
330315
331316 Py_ssize_t len = Py_SIZE (v );
332317 PyObject * * item = v -> ob_item ;
333- Py_uhash_t acc = _PyHASH_XXPRIME_5 ;
318+ Py_uhash_t acc = _PyTuple_HASH_XXPRIME_5 ;
334319 for (Py_ssize_t i = 0 ; i < len ; i ++ ) {
335320 Py_uhash_t lane = PyObject_Hash (item [i ]);
336321 if (lane == (Py_uhash_t )- 1 ) {
337322 return -1 ;
338323 }
339- acc += lane * _PyHASH_XXPRIME_2 ;
340- acc = _PyHASH_XXROTATE (acc );
341- acc *= _PyHASH_XXPRIME_1 ;
324+ acc += lane * _PyTuple_HASH_XXPRIME_2 ;
325+ acc = _PyTuple_HASH_XXROTATE (acc );
326+ acc *= _PyTuple_HASH_XXPRIME_1 ;
342327 }
343328
344329 /* Add input length, mangled to keep the historical value of hash(()). */
345- acc += len ^ (_PyHASH_XXPRIME_5 ^ 3527539UL );
330+ acc += len ^ (_PyTuple_HASH_XXPRIME_5 ^ 3527539UL );
346331
347332 if (acc == (Py_uhash_t )- 1 ) {
348333 acc = 1546275796 ;
0 commit comments