Author: Matti Picus <[email protected]>
Branch:
Changeset: r91417:fb4031e88779
Date: 2017-05-26 00:36 +0300
http://bitbucket.org/pypy/pypy/changeset/fb4031e88779/
Log: more places to convert hash value -1 to -2, see comments to issue
#2346
diff --git a/pypy/objspace/std/bufferobject.py
b/pypy/objspace/std/bufferobject.py
--- a/pypy/objspace/std/bufferobject.py
+++ b/pypy/objspace/std/bufferobject.py
@@ -112,7 +112,9 @@
descr_ge = _make_descr__cmp('ge')
def descr_hash(self, space):
- return space.newint(compute_hash(self.buf.as_str()))
+ x = compute_hash(self.buf.as_str())
+ x -= (x == -1) # convert -1 to -2 without creating a bridge
+ return space.newint(x)
def descr_mul(self, space, w_times):
# xxx not the most efficient implementation
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -592,6 +592,7 @@
def descr_hash(self, space):
x = compute_hash(self._value)
+ x -= (x == -1) # convert -1 to -2 without creating a bridge
return space.newint(x)
def descr_format(self, space, __args__):
diff --git a/pypy/objspace/std/unicodeobject.py
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -239,6 +239,7 @@
def descr_hash(self, space):
x = compute_hash(self._value)
+ x -= (x == -1) # convert -1 to -2 without creating a bridge
return space.newint(x)
def descr_eq(self, space, w_other):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit