Large Dictionaries
Duncan Booth
duncan.booth at invalid.invalid
Tue May 16 06:37:04 EDT 2006
John Machin wrote:
>> (my dictionary values are all None).
>
> So in fact all you need is a set. Have you experimented with the Python
> 2.5 alpha?
>
I don't think that will help him: my timings work out about the same on
2.4.2 or 2.5a2. As I pointed out, the bottleneck is creating the tuples.
Creating either a dictionary or a set from 5 million tuples takes a similar
amount of time (about 6 seconds on my system).
BTW, a string key is quite a bit faster than the tuples, even though you
end up with as many temporary tuples during the process:
>>> scale = 2**32
>>> data = [ "%d:%d" % (i*scale,i) for i in range(5000000) ]
>>> d = set(data)
takes about 18 seconds to create the data list and 5 for the set.
More information about the Python-list
mailing list