On 2006-07-12, Qiangning Hong <[EMAIL PROTECTED]> wrote:
> Grant Edwards wrote:
>> On 2006-07-11, Qiangning Hong <[EMAIL PROTECTED]> wrote:
>> > However, when I come to Python's builtin hash() function, I
>> > found it produces different values in my two computers!  In a
>> > pentium4, hash('a') -> -468864544; in a amd64, hash('a') ->
>> > 12416037344.  Does hash function depend on machine's word
>> > length?
>>
>> Apparently. :)
>>
>> The low 32 bits match, so perhaps you should just use that
>> portion of the returned hash?
>>
>> >>> hex(12416037344)
>> '0x2E40DB1E0L'
>> >>> hex(-468864544 & 0xffffffffffffffff)
>> '0xFFFFFFFFE40DB1E0L'
>>
>> >>> hex(12416037344 & 0xffffffff)
>> '0xE40DB1E0L'
>> >>> hex(-468864544 & 0xffffffff)
>> '0xE40DB1E0L'
>
> Is this relationship (same low 32 bits) guaranteed?

No, I don't believe so.

> Will it change in the future version?

It may.

-- 
Grant Edwards                   grante             Yow!  Is this an out-take
                                  at               from the "BRADY BUNCH"?
                               visi.com            
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to