Skip to content

scalar int hashing broken on 64 bit python3 #3793

Closed

Description

@juliantaylor
In [1]: import numpy as np;
In [2]: i=2**31;
In [3]: print(np.int64(i) in {i:111})
False
In [6]: print(hash(np.int64(i)), hash(i))
(-2147483648, 2147483648)

on python2 it returns True,
discovered on s390x where hash(np.int64(4) returns zero because int_arrtype_hash casts the object to PyIntScalarObject which cuts of four bytes (as its really PyLongScalarObject) which are zero on big endian:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=724047

This is probably also the cause of the difference on amd64.

most likely also the cause scipy/scipy#2930

Activity

  1. added 2 commits that reference this issue on Sep 27, 2013
    a81fd3f
    2960056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions