robtandy / randomdict

Python dictionaries with O(1) random element access.
58 stars 6 forks source link

Fixes errors caused when initializing with dict arg, among others. #6

Open emeryberger opened 2 months ago

emeryberger commented 2 months ago

Example of bug and fix

from randomdict import RandomDict

q = RandomDict({ i : i * i for i in range(10) })
print(list(q.items()))

Before (ignores initialization):

[]

After (properly initialized):

[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25), (6, 36), (7, 49), (8, 64), (9, 81)]