gh-111389: Add PyHASH_MULTIPLIER constant#119214
Conversation
|
The private A code search on PyPI top 7,500 projects (2024-03-16) finds 4 projects using it:
|
Sorry, something went wrong.
gpshead
left a comment
There was a problem hiding this comment.
This makes sense, no harm in this being public even if I think it is odd that anyone uses it.
Sorry, something went wrong.
It's a good prime number to increase to implement good hash function. Using a random number can lead to more collision. cc @mdickinson |
Sorry, something went wrong.
Change seems reasonable to me; the value is potentially useful to have available if you're implementing something complex-like in a C extension and need equality to behave well with respect to Python's |
Sorry, something went wrong.
I don't know about the specific case of floating point objects, but the constant is used by at least 4 projects: #119214 (comment) |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
(cherry picked from commit f6da790) Co-authored-by: Victor Stinner <vstinner@python.org>
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot wasm32-wasi 3.13 has failed when building commit 1177897. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/all/#builders/1502/builds/133 Failed tests:
Summary of the results of the build (if available): == Click to see traceback logsremote: Enumerating objects: 19, done.
remote: Counting objects: 5% (1/18)
remote: Counting objects: 11% (2/18)
remote: Counting objects: 16% (3/18)
remote: Counting objects: 22% (4/18)
remote: Counting objects: 27% (5/18)
remote: Counting objects: 33% (6/18)
remote: Counting objects: 38% (7/18)
remote: Counting objects: 44% (8/18)
remote: Counting objects: 50% (9/18)
remote: Counting objects: 55% (10/18)
remote: Counting objects: 61% (11/18)
remote: Counting objects: 66% (12/18)
remote: Counting objects: 72% (13/18)
remote: Counting objects: 77% (14/18)
remote: Counting objects: 83% (15/18)
remote: Counting objects: 88% (16/18)
remote: Counting objects: 94% (17/18)
remote: Counting objects: 100% (18/18)
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 8% (1/12)
remote: Compressing objects: 16% (2/12)
remote: Compressing objects: 25% (3/12)
remote: Compressing objects: 33% (4/12)
remote: Compressing objects: 41% (5/12)
remote: Compressing objects: 50% (6/12)
remote: Compressing objects: 58% (7/12)
remote: Compressing objects: 66% (8/12)
remote: Compressing objects: 75% (9/12)
remote: Compressing objects: 83% (10/12)
remote: Compressing objects: 91% (11/12)
remote: Compressing objects: 100% (12/12)
remote: Compressing objects: 100% (12/12), done.
remote: Total 19 (delta 6), reused 9 (delta 6), pack-reused 1
From https://github.com/python/cpython
* branch 3.13 -> FETCH_HEAD
Note: switching to '1177897551066c1e8c394809152614a6483f9ce7'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 1177897551 [3.13] gh-111389: Add PyHASH_MULTIPLIER constant (GH-119214) (#119334)
Switched to and reset branch '3.13'
configure: WARNING: no system libmpdecimal found; falling back to bundled libmpdecimal (deprecated and scheduled for removal in Python 3.15)
configure: WARNING: using cross tools not prefixed with host triplet
configure: WARNING: no system libmpdecimal found; falling back to bundled libmpdecimal (deprecated and scheduled for removal in Python 3.15)
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:130:11: warning: 'htole32' macro redefined [-Wmacro-redefined]
130 | # define htole32(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:43:9: note: previous definition is here
43 | #define htole32(x) (uint32_t)(x)
| ^
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:131:11: warning: 'le32toh' macro redefined [-Wmacro-redefined]
131 | # define le32toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:44:9: note: previous definition is here
44 | #define le32toh(x) (uint32_t)(x)
| ^
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:132:11: warning: 'htobe32' macro redefined [-Wmacro-redefined]
132 | # define htobe32(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:37:9: note: previous definition is here
37 | #define htobe32(x) __bswap32(x)
| ^
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:138:11: warning: 'be32toh' macro redefined [-Wmacro-redefined]
138 | # define be32toh(x) (htobe32((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:38:9: note: previous definition is here
38 | #define be32toh(x) __bswap32(x)
| ^
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:140:11: warning: 'htole64' macro redefined [-Wmacro-redefined]
140 | # define htole64(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:45:9: note: previous definition is here
45 | #define htole64(x) (uint64_t)(x)
| ^
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:141:11: warning: 'le64toh' macro redefined [-Wmacro-redefined]
141 | # define le64toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:46:9: note: previous definition is here
46 | #define le64toh(x) (uint64_t)(x)
| ^
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:142:11: warning: 'htobe64' macro redefined [-Wmacro-redefined]
142 | # define htobe64(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:39:9: note: previous definition is here
39 | #define htobe64(x) __bswap64(x)
| ^
In file included from ../../Modules/md5module.c:46:
In file included from ../../Modules/_hacl/Hacl_Hash_MD5.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:149:11: warning: 'be64toh' macro redefined [-Wmacro-redefined]
149 | # define be64toh(x) (htobe64((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:40:9: note: previous definition is here
40 | #define be64toh(x) __bswap64(x)
| ^
8 warnings generated.
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:130:11: warning: 'htole32' macro redefined [-Wmacro-redefined]
130 | # define htole32(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:43:9: note: previous definition is here
43 | #define htole32(x) (uint32_t)(x)
| ^
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:131:11: warning: 'le32toh' macro redefined [-Wmacro-redefined]
131 | # define le32toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:44:9: note: previous definition is here
44 | #define le32toh(x) (uint32_t)(x)
| ^
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:132:11: warning: 'htobe32' macro redefined [-Wmacro-redefined]
132 | # define htobe32(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:37:9: note: previous definition is here
37 | #define htobe32(x) __bswap32(x)
| ^
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:138:11: warning: 'be32toh' macro redefined [-Wmacro-redefined]
138 | # define be32toh(x) (htobe32((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:38:9: note: previous definition is here
38 | #define be32toh(x) __bswap32(x)
| ^
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:140:11: warning: 'htole64' macro redefined [-Wmacro-redefined]
140 | # define htole64(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:45:9: note: previous definition is here
45 | #define htole64(x) (uint64_t)(x)
| ^
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:141:11: warning: 'le64toh' macro redefined [-Wmacro-redefined]
141 | # define le64toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:46:9: note: previous definition is here
46 | #define le64toh(x) (uint64_t)(x)
| ^
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:142:11: warning: 'htobe64' macro redefined [-Wmacro-redefined]
142 | # define htobe64(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:39:9: note: previous definition is here
39 | #define htobe64(x) __bswap64(x)
| ^
In file included from ../../Modules/sha1module.c:47:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA1.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:149:11: warning: 'be64toh' macro redefined [-Wmacro-redefined]
149 | # define be64toh(x) (htobe64((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:40:9: note: previous definition is here
40 | #define be64toh(x) __bswap64(x)
| ^
8 warnings generated.
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:130:11: warning: 'htole32' macro redefined [-Wmacro-redefined]
130 | # define htole32(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:43:9: note: previous definition is here
43 | #define htole32(x) (uint32_t)(x)
| ^
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:131:11: warning: 'le32toh' macro redefined [-Wmacro-redefined]
131 | # define le32toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:44:9: note: previous definition is here
44 | #define le32toh(x) (uint32_t)(x)
| ^
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:132:11: warning: 'htobe32' macro redefined [-Wmacro-redefined]
132 | # define htobe32(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:37:9: note: previous definition is here
37 | #define htobe32(x) __bswap32(x)
| ^
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:138:11: warning: 'be32toh' macro redefined [-Wmacro-redefined]
138 | # define be32toh(x) (htobe32((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:38:9: note: previous definition is here
38 | #define be32toh(x) __bswap32(x)
| ^
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:140:11: warning: 'htole64' macro redefined [-Wmacro-redefined]
140 | # define htole64(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:45:9: note: previous definition is here
45 | #define htole64(x) (uint64_t)(x)
| ^
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:141:11: warning: 'le64toh' macro redefined [-Wmacro-redefined]
141 | # define le64toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:46:9: note: previous definition is here
46 | #define le64toh(x) (uint64_t)(x)
| ^
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:142:11: warning: 'htobe64' macro redefined [-Wmacro-redefined]
142 | # define htobe64(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:39:9: note: previous definition is here
39 | #define htobe64(x) __bswap64(x)
| ^
In file included from ../../Modules/sha3module.c:59:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA3.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:149:11: warning: 'be64toh' macro redefined [-Wmacro-redefined]
149 | # define be64toh(x) (htobe64((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:40:9: note: previous definition is here
40 | #define be64toh(x) __bswap64(x)
| ^
8 warnings generated.
../../Modules/expat/xmlparse.c:7839:11: warning: format specifies type 'int' but the argument has type 'ptrdiff_t' (aka 'long') [-Wformat]
7838 | " (+" EXPAT_FMT_PTRDIFF_T("6") " bytes %s|%d, xmlparse.c:%d) %*s\"",
| ~~~~~~~~~~~~~~~~~~~~~~~~
7839 | bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP",
| ^~~~~~~~~
1 warning generated.
../../Modules/_testinternalcapi/test_critical_sections.c:142:1: warning: unused function 'thread_critical_sections' [-Wunused-function]
142 | thread_critical_sections(void *arg)
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
../../Modules/posixmodule.c:7859:1: warning: unused function 'warn_about_fork_with_threads' [-Wunused-function]
7859 | warn_about_fork_with_threads(const char* name)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:130:11: warning: 'htole32' macro redefined [-Wmacro-redefined]
130 | # define htole32(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:43:9: note: previous definition is here
43 | #define htole32(x) (uint32_t)(x)
| ^
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:131:11: warning: 'le32toh' macro redefined [-Wmacro-redefined]
131 | # define le32toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:44:9: note: previous definition is here
44 | #define le32toh(x) (uint32_t)(x)
| ^
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:132:11: warning: 'htobe32' macro redefined [-Wmacro-redefined]
132 | # define htobe32(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:37:9: note: previous definition is here
37 | #define htobe32(x) __bswap32(x)
| ^
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:138:11: warning: 'be32toh' macro redefined [-Wmacro-redefined]
138 | # define be32toh(x) (htobe32((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:38:9: note: previous definition is here
38 | #define be32toh(x) __bswap32(x)
| ^
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:140:11: warning: 'htole64' macro redefined [-Wmacro-redefined]
140 | # define htole64(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:45:9: note: previous definition is here
45 | #define htole64(x) (uint64_t)(x)
| ^
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:141:11: warning: 'le64toh' macro redefined [-Wmacro-redefined]
141 | # define le64toh(x) (x)
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:46:9: note: previous definition is here
46 | #define le64toh(x) (uint64_t)(x)
| ^
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:142:11: warning: 'htobe64' macro redefined [-Wmacro-redefined]
142 | # define htobe64(x) \
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:39:9: note: previous definition is here
39 | #define htobe64(x) __bswap64(x)
| ^
In file included from ../../Modules/sha2module.c:48:
In file included from ../../Modules/_hacl/Hacl_Hash_SHA2.h:35:
In file included from ../../Modules/_hacl/include/krml/types.h:12:
../../Modules/_hacl/include/krml/lowstar_endianness.h:149:11: warning: 'be64toh' macro redefined [-Wmacro-redefined]
149 | # define be64toh(x) (htobe64((x)))
| ^
/opt/wasi-sdk-21.0/bin/../share/wasi-sysroot/include/endian.h:40:9: note: previous definition is here
40 | #define be64toh(x) __bswap64(x)
| ^
8 warnings generated.
Kill <WorkerThread #1 running test=test_math pid=2536312 time=25 min> process group
Kill <WorkerThread #1 running test=test_statistics pid=2552347 time=25 min> process group
make: *** [Makefile:2210: buildbottest] Error 2
Cannot open file '/home/buildbot/buildarea/3.13.bcannon-wasi.wasi.debug/build/build/cross-build/wasm32-wasi/test-results.xml' for upload |
Sorry, something went wrong.
📚 Documentation preview 📚: https://cpython-previews--119214.org.readthedocs.build/