[Python-Dev] Python hash function

damien morton dmorton@bitfurnace.com
Wed, 25 Jun 2003 01:24:23 -0400


I do know about ob_shash, and youre probably right that most strings
used by pystone are interned. Even so, my running python/pystone through
vtune showed that as much time is spent in string_hash() as
lookdict_string(). Lookdict_string() is, of course, called many more
times than string_hash() - but the total self time for each function is
comparable.

Not only does the current hash function use a multiply for every
character, but it doesn't parralelise very well. The functions I have
been playing with are about 4 times faster than the current function,
while using only half the multiplies, adds and loop iterations.

> -----Original Message-----
> From: Neil Schemenauer [mailto:nas-python@python.ca] 
> Sent: Wednesday, 25 June 2003 00:27
> To: damien.morton@acm.org
> Cc: python-dev@python.org
> Subject: Re: [Python-Dev] Python hash function
> 
> 
> Damien Morton wrote:
> > Maddeningly, I havent been able to translate these near-perfect 
> > distributions into improvements in pystones.
> 
> No time to look at this in deal but do you know about 
> ob_shash?  I suspect most strings used by pystone are interned.
> 
>   Neil