[pypy-commit] pypy default: remove bridge potential in hashing (int, int) tuples
cfbolz
pypy.commits at gmail.com
Sat Aug 5 16:33:20 EDT 2017
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r92092:b235c624a167
Date: 2017-08-05 22:32 +0200
http://bitbucket.org/pypy/pypy/changeset/b235c624a167/
Log: remove bridge potential in hashing (int, int) tuples
diff --git a/pypy/objspace/std/specialisedtupleobject.py b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -74,8 +74,7 @@
elif typetuple[i] == int:
# mimic cpythons behavior of a hash value of -2 for -1
y = value
- if y == -1:
- y = -2
+ y -= (y == -1) # No explicit condition, to avoid JIT bridges
elif typetuple[i] == float:
# get the correct hash for float which is an
# integer & other less frequent cases
diff --git a/pypy/objspace/std/test/test_specialisedtupleobject.py b/pypy/objspace/std/test/test_specialisedtupleobject.py
--- a/pypy/objspace/std/test/test_specialisedtupleobject.py
+++ b/pypy/objspace/std/test/test_specialisedtupleobject.py
@@ -37,6 +37,7 @@
self.space.eq(self.space.hash(N_w_tuple),
self.space.hash(S_w_tuple)))
+ hash_test([-1, -1])
hash_test([1, 2])
hash_test([1.5, 2.8])
hash_test([1.0, 2.0])
More information about the pypy-commit
mailing list