[pypy-commit] pypy default: Document the purpose of _hash_int() more

arigo pypy.commits at gmail.com
Wed May 9 13:46:35 EDT 2018


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r94516:662b52963394
Date: 2018-05-09 19:45 +0200
http://bitbucket.org/pypy/pypy/changeset/662b52963394/

Log:	Document the purpose of _hash_int() more

diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -895,4 +895,9 @@
     # The complete list of built-in types whose hash should be
     # consistent is: int, long, bool, float, complex.
     #
+    # Note: the same function in PyPy3 does far more computations.
+    # So you should call _hash_int() only when you want to get the exact
+    # same result as hash(integer) does on app-level, and not merely to
+    # adjust some unrelated hash result from -1 to -2.
+    #
     return a - (a == -1)  # No explicit condition, to avoid JIT bridges


More information about the pypy-commit mailing list