MagicStack / immutables

A high-performance immutable mapping type for Python.
Other
1.14k stars 57 forks source link

Iteration Bug fix: #85

Closed molaxx closed 2 years ago

molaxx commented 2 years ago

Assumption that there are max number of levels 7 is wrong, a collision at the 7 level creates a collision node in the 8th level, this causes iteration to stop prematurely.

for reproduction (before the fix): PYTHONHASHSEED=0 python <<EOF import itertools import immutables import random seed=b"b\xe6\xe2\x82\xe5\xc1e|" r = random.Random(seed) a = immutables.Map( zip( (r.randrange(0, 10000000000) for i in range(820000)), itertools.repeat(None, 820000), ) ) len1 = len(a) len2 = len(tuple(a)) if len1 != len2: print(f"BADDDD seed:{seed} len(a)={len1} len(tuple(a))={len2}")

EOF

1st1 commented 2 years ago

I've created a new PR that adds a test https://github.com/MagicStack/immutables/pull/87