[IronPython] Hashing in IronPython
Michael Foord
fuzzyman at voidspace.org.uk
Thu Feb 28 14:03:40 PST 2008
At Resolver Systems we are seeing IronPython use a radically lower
amount of unique hashes for tuples - which we *believe* may be at the
root of a performance problem with using dictionaries keyed by tuples.
CPython 2.5
>>> hashes = set()
>>> for i in range(1000):
... for j in range(1000):
... hashes.add(hash((i, j)))
...
>>> len(hashes)
1000000
Same code on IronPython 2:
IronPython 2.0 Alpha (2.0.0.800) on .NET 2.0.50727.1433
Copyright (c) Microsoft Corporation. All rights reserved.
>>> hashes = set()
>>> for i in range(1000):
... for j in range(1000):
... hashes.add(hash((i, j)))
...
>>> len(hashes)
32768
>>>
We have a work around (using 2D arrays instead of dictionaries) but as
dictionaries are heavily used in Python it is likely to be a problem for
others as well.
All the best,
Michael Foord
http://www.manning.com/foord
More information about the Users
mailing list