Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Hash to longs, and Decimal

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


facundobatista at gmail

Sep 17, 2007, 1:58 PM

Post #1 of 3 (347 views)
Permalink
Hash to longs, and Decimal

Hi everybody!

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.

This allows changes in Decimal that lead to a better hashing behaviour
for big, big, really big numbers.

The patch applies cleanly, all the tests pass ok (Mark also provided
more tests for the hash function).

I won't commit this right now; I'll delay the change for a couple of
days in case somebody wants to take a look at it.

Thanks!

--
. Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


guido at python

Sep 17, 2007, 2:17 PM

Post #2 of 3 (352 views)
Permalink
Re: Hash to longs, and Decimal [In reply to]

Seems a fine idea. I don't have the time for a code review but I'll
leave that up to you all.

--Guido

On 9/17/07, Facundo Batista <facundobatista [at] gmail> wrote:
> Hi everybody!
>
> 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.
>
> This allows changes in Decimal that lead to a better hashing behaviour
> for big, big, really big numbers.
>
> The patch applies cleanly, all the tests pass ok (Mark also provided
> more tests for the hash function).
>
> I won't commit this right now; I'll delay the change for a couple of
> days in case somebody wants to take a look at it.
>
> Thanks!
>
> --
> . Facundo
>
> Blog: http://www.taniquetil.com.ar/plog/
> PyAr: http://www.python.org/ar/
> _______________________________________________
> Python-Dev mailing list
> Python-Dev [at] python
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
>


--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


dickinsm at gmail

Sep 17, 2007, 2:50 PM

Post #3 of 3 (325 views)
Permalink
Re: Hash to longs, and Decimal [In reply to]

On 9/17/07, Facundo Batista <facundobatista [at] gmail> 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

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.