[IronPython] Hashing in IronPython

Dino Viehland dinov at exchange.microsoft.com
Fri Feb 29 02:15:10 CET 2008


I'll fix this for the next release.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Thursday, February 28, 2008 2:04 PM
To: Discussion of IronPython
Subject: [IronPython] Hashing in IronPython

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
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list