8000 gh-94155: Reduce hash collisions for code objects by sweeneyde · Pull Request #100183 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-94155: Reduce hash collisions for code objects #100183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SCRAMBLE_IN_HASH macro
  • Loading branch information
sweeneyde committed Dec 19, 2022
commit 2014fb13e87b9885e650ab0b5d22af28ddf62237
24 changes: 12 additions & 12 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1847,20 +1847,20 @@ code_hash(PyCodeObject *co)
uhash ^= (Py_uhash_t)(H); \
uhash *= _PyHASH_MULTIPLIER; \
} while (0)
#define SCRAMBLE_IN_OR_ERR(EXPR) do { \
Py_hash_t h = (EXPR); \
if (h == -1) { \
return -1; \
} \
SCRAMBLE_IN(h); \
#define SCRAMBLE_IN_HASH(EXPR) do { \
Py_hash_t h = PyObject_Hash(EXPR); \
if (h == -1) { \
return -1; \
} \
SCRAMBLE_IN(h); \
} while (0)

SCRAMBLE_IN_OR_ERR(PyObject_Hash(co->co_name));
SCRAMBLE_IN_OR_ERR(PyObject_Hash(co->co_consts));
SCRAMBLE_IN_OR_ERR(PyObject_Hash(co->co_names));
SCRAMBLE_IN_OR_ERR(PyObject_Hash(co->co_localsplusnames));
SCRAMBLE_IN_OR_ERR(PyObject_Hash(co->co_linetable));
SCRAMBLE_IN_OR_ERR(PyObject_Hash(co->co_exceptiontable));
SCRAMBLE_IN_HASH(co->co_name);
SCRAMBLE_IN_HASH(co->co_consts);
SCRAMBLE_IN_HASH(co->co_names);
SCRAMBLE_IN_HASH(co->co_localsplusnames);
SCRAMBLE_IN_HASH(co->co_linetable);
SCRAMBLE_IN_HASH(co->co_exceptiontable);
SCRAMBLE_IN(co->co_argcount);
SCRAMBLE_IN(co->co_posonlyargcount);
SCRAMBLE_IN(co->co_kwonlyargcount);
Expand Down
0