[Python-bugs-list] [ python-Bugs-689659 ] 64-bit int and long hash keys incompatible
SourceForge.net
noreply@sourceforge.net
Wed, 19 Feb 2003 15:17:40 -0800
Bugs item #689659, was opened at 2003-02-19 23:17
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=689659&group_id=5470
Category: Python Interpreter Core
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark Dickinson (marketdickinson)
Assigned to: Nobody/Anonymous (nobody)
Summary: 64-bit int and long hash keys incompatible
Initial Comment:
For 64-bit platforms, it seems that ints and longs with the
same value don't necessarily give the same hash key.
An example is below; the phenomenon seems to occur
for a range of numbers between 2**32 and 2**64.
I assume this is unintentional? It looks suspiciously as
though the function long_hash in Objects/longobject.c
has 32-bitness hard-coded. Lines 1288-1289 of that file
in the Python 2.2.2 source read:
/* Force a 32-bit circular shift */
x = ((x << SHIFT) & ~MASK) | ((x >> (32-SHIFT)) &
MASK);
And here's the Python example:
Python 2.2.2 (#22, Dec 23 2002, 12:02:55)
[GCC 3.0.3] on sunos5
Type "help", "copyright", "credits" or "license" for more
information.
>>> x = 4503599627370496L
>>> y = 4503599627370496
>>> h = {x: 'anything', y: 'something else'}
>>> h[x]
'anything'
>>> h[y]
'something else'
>>> x == y
1
All the best,
Mark
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=689659&group_id=5470