[Python-ideas] dict changes [was: Ordered storage of keyword arguments]

Antoine Pitrou solipsis at pitrou.net
Fri Oct 29 11:06:22 CEST 2010


Le vendredi 29 octobre 2010 à 10:51 +0200, M.-A. Lemburg a écrit :
> > 
> > I've thought about that. The main annoyance is to be able to switch
> > transparently between the two implementations. But I think it would be
> > interesting to pursue that effort, since indeed dicts with interned keys
> > are the most common case of dicts in the average Python workload. Saving
> > 1/3 of the memory size on these dicts would be worthwhile IMO.
> 
> Are you sure ? In the age of GB RAM, runtime performance appears
> to be more important than RAM usage.
> Moving the hash comparison out
> of the dict would likely cause (cache) locality to no longer trigger.

Good point. It probably depends on the collision rate.
Also, a string key dict could be optimized for interned strings, in
which case the hash comparison is unnecessary.
(knowing whether the key is interned could be stored in e.g. the
low-order bit of the key pointer)

Regards

Antoine.





More information about the Python-ideas mailing list