Closed
Description
Bug report
Bug description:
Originally reported by @ThomasBr0 in #132762
The _Py_bit_length()
and _BitScanReverse64()
code paths are incorrect and don't always return the smallest log2 key size to fit the desired number of items. The bug is benign in the sense that the dictionaries are sometimes too big, but they're never too small.
For example calculate_log2_keysize(7) = 4
but calculate_log2_keysize(8) = 3
.
Lines 545 to 566 in 9546eee
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response