Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hash(-1) in numba is not correct #2572

Closed
jolos opened this issue Oct 24, 2017 · 2 comments
Closed

hash(-1) in numba is not correct #2572

jolos opened this issue Oct 24, 2017 · 2 comments
Labels
Milestone

Comments

@jolos
Copy link

jolos commented Oct 24, 2017

As the '-1' hash value is reserved in python, hash(-1) == -2. But in numba hash(-1) == -1.
A small difference, but could lead to weird bugs.

@seibert
Copy link
Contributor

seibert commented Oct 31, 2017

See this for more details:

http://effbot.org/zone/python-hash.htm

@seibert seibert added the bug label Oct 31, 2017
@seibert seibert added this to the Numba 0.37 RC milestone Oct 31, 2017
@sklam
Copy link
Member

sklam commented Feb 6, 2018

CPython is automatically fixing __hash__ that returns -1 to -2 because -1 is a special value for indicating error. It is a implementation specific thing that I don't think numba needs to follow.

Users should treat numba as a different python implementation that lives within the Python interpreter, such that implementation details can be different. Numba does not need to guarantee the hash() function for various types matches the implementation of CPython. In fact, the hashing algorithm in CPython can be different in each version.

@sklam sklam closed this as completed Feb 6, 2018
@sklam sklam added wontfix and removed bug labels Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants