[Python-Dev] Hash to longs, and Decimal

Mark Dickinson dickinsm at gmail.com
Mon Sep 17 23:50:45 CEST 2007


On 9/17/07, Facundo Batista <facundobatista at gmail.com> wrote:
>
> In the Tracker Issue...
>
>   http://bugs.python.org/issue1772851
>
> ... Mark Dickinson came with a patch that alters in a very corner case
> how the hash is calculated to a long integer.
>

Much as I'd like this patch to be applied, I feel compelled to point out
that it does have a significant(?) downside:  it slows down hashing of large
integers to some degree.

On my machine (Dual Xeon 2.8Ghz/SuSE Linux 10.2/gcc 4.1 with -O3), using
timeit.timeit('hash(n)') to get timings, the new hash function takes 70%
more time for 1000 digit integers, 20% longer for 100 digit integers, but
has no measurable performance impact for small (int-sized) longs.  I don't
know how significant this performance hit is in the larger scheme of things.

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070917/9a327041/attachment.htm 


More information about the Python-Dev mailing list