Closed GoogleCodeExporter closed 9 years ago
Since the gmpy_test.py file is empty, I can't recreate the original issue. I
think
the correct solution is to a long for the hash. Using the attached patch, I
tested a
wide variety of values and verified that hash(long) always equaled hash(mpz).
casevh
Original comment by casevh
on 22 May 2008 at 5:43
Attachments:
Here's gmpy_test.py
Original comment by rel...@osagesoftware.com
on 22 May 2008 at 11:41
Attachments:
I've run gmpy_test.py with gmpy.c(r17) and my version. There are failures with
r17
and no failures with my version. The attached file shows runs (with both
versions)
as well as the output of "svn diff", "setup.py build", and "setup.py install"
Original comment by rel...@osagesoftware.com
on 22 May 2008 at 10:26
Attachments:
Thank you for gmpy_test.py. I runs successfully with r18.
Your patch runs gmpy_test.py successfully but breaks the following:
>>> import gmpy
>>> hash(long('12345678901234567890'))
-6101065172474983726
>>> hash(gmpy.mpz('1234567901234567890'))
338664146
At least on my system, hash appears to be a 64-bit value.
Can you test r18?
casevh
Original comment by casevh
on 23 May 2008 at 4:28
I can duplicate your results for hash(long()) and hash(gmpy.mpz()) for my
patch.
However running R18 produces -6101065172474983726 and 1234567901234567890.
*** R18 ***
Python 2.5.2 (r252:60911, May 16 2008, 23:11:42)
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmpy
>>> print hash(long('12345678901234567890'))
-6101065172474983726
>>> print hash(gmpy.mpz('1234567901234567890'))
1234567901234567890
>>>
*** My Patch ***
Python 2.5.2 (r252:60911, May 16 2008, 23:11:42)
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmpy
>>> print hash(long('12345678901234567890'))
-6101065172474983726
>>> print hash(gmpy.mpz('1234567901234567890'))
338664146
>>>
Original comment by rel...@osagesoftware.com
on 23 May 2008 at 11:48
hash(gmpy.mpz('1234567901234567890')) is missing an "8".
Since your hash values match mine, I'll mark this issue as fixed.
Thanks for the bug report.
casevh
Original comment by casevh
on 23 May 2008 at 1:05
Thanks for the fix!
Original comment by rel...@osagesoftware.com
on 24 May 2008 at 3:54
Original issue reported on code.google.com by
rel...@osagesoftware.com
on 5 Jan 2008 at 2:24Attachments: