[Python-ideas] dict.hash - optimized per module

Chris Rebert pyideas at rebertia.com
Sun Oct 17 11:52:27 CEST 2010

On Sun, Oct 17, 2010 at 2:41 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, 17 Oct 2010 06:27:37 pm Jan Koprowski wrote:
>>   After watching I made graph, using presented at conference library
>> dictinfo, for __builtin__.__dict__.
>>   When I saw few collisions I think "Why this module doesn't have
>> their own hashing function implementation which allow to avoid
>> collision in this set of names?".
> Firstly, the occasional collision doesn't matter much.
> Secondly, your idea would mean that every module would need it's own
> custom-made hash function. Writing good hash functions is hard. The
> Python hash function is very, very good. Expecting developers to
> produce *dozens* of hash functions equally as good is totally
> impractical.

Actually, there's already software to automatically generate such
functions; e.g. http://www.gnu.org/software/gperf/
Not that this makes the suggestion any more tractable though.


More information about the Python-ideas mailing list