Visitar URL original
gh-94155: Reduce hash collisions for code objects by sweeneyde · Pull Request #100183 · python/cpython · GitHub
Skip to content
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
don't compare unsigned to signed
  • Loading branch information
sweeneyde committed Dec 12, 2022
commit 3c38f5a0efb2b4dce2f406229cd4a1b7ba2b7c65
12 changes: 6 additions & 6 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1834,10 +1834,10 @@ code_richcompare(PyObject *self, PyObject *other, int op)
static Py_hash_t
code_hash(PyCodeObject *co)
{
Py_uhash_t res = 20221211;
#define SCRAMBLE_IN(H) do { \
res ^= (Py_uhash_t)(H); \
res *= _PyHASH_MULTIPLIER; \
Py_uhash_t uhash = 20221211;
#define SCRAMBLE_IN(H) do { \
uhash ^= (Py_uhash_t)(H); \
uhash *= _PyHASH_MULTIPLIER; \
} while (0)
#define SCRAMBLE_IN_OR_ERR(EXPR) do { \
Py_hash_t h = (EXPR); \
Expand Down Expand Up @@ -1865,10 +1865,10 @@ code_hash(PyCodeObject *co)
SCRAMBLE_IN(co_instr);
i += _PyOpcode_Caches[_Py_OPCODE(co_instr)];
}
if (res == -1) {
if ((Py_hash_t)uhash == -1) {
return -2;
}
return res;
return (Py_hash_t)uhash;
}


Expand Down