[pypy-commit] pypy py3.5: sys.hash_info.algorithm = 'rpython'
amauryfa
pypy.commits at gmail.com
Thu Sep 22 17:34:28 EDT 2016
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.5
Changeset: r87334:4d4125dd1c84
Date: 2016-09-22 23:31 +0200
http://bitbucket.org/pypy/pypy/changeset/4d4125dd1c84/
Log: sys.hash_info.algorithm = 'rpython' The algorithm looks like
CPython's 'fnv' function, but does not use 8 bytes blocks.
This unblocks running tests with the "-v" option.
diff --git a/pypy/module/sys/system.py b/pypy/module/sys/system.py
--- a/pypy/module/sys/system.py
+++ b/pypy/module/sys/system.py
@@ -5,6 +5,7 @@
from pypy.objspace.std.complexobject import HASH_IMAG
from pypy.objspace.std.floatobject import HASH_INF, HASH_NAN
from pypy.objspace.std.intobject import HASH_MODULUS
+from pypy.objspace.std.bytesobject import HASH_ALGORITHM
from pypy.interpreter import gateway
from rpython.rlib import rbigint, rfloat
from rpython.rtyper.lltypesystem import lltype, rffi
@@ -38,6 +39,7 @@
inf = structseqfield(2)
nan = structseqfield(3)
imag = structseqfield(4)
+ algorithm = structseqfield(5)
class thread_info(metaclass=structseqtype):
name = structseqfield(0)
@@ -80,6 +82,7 @@
space.wrap(HASH_INF),
space.wrap(HASH_NAN),
space.wrap(HASH_IMAG),
+ space.wrap(HASH_ALGORITHM),
]
w_hash_info = app.wget(space, "hash_info")
return space.call_function(w_hash_info, space.newtuple(info_w))
diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -201,6 +201,7 @@
assert isinstance(li.inf, int)
assert isinstance(li.nan, int)
assert isinstance(li.imag, int)
+ assert isinstance(li.algorithm, str)
def test_sys_exit(self):
import sys
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
@@ -3,7 +3,7 @@
from rpython.rlib.jit import we_are_jitted
from rpython.rlib.objectmodel import (
compute_hash, compute_unique_id, import_from_mixin, newlist_hint,
- resizelist_hint)
+ resizelist_hint, HASH_ALGORITHM)
from rpython.rlib.buffer import StringBuffer
from rpython.rlib.rstring import StringBuilder
@@ -16,7 +16,6 @@
from pypy.objspace.std.util import IDTAG_SPECIAL, IDTAG_SHIFT
from pypy.objspace.std.formatting import mod_format, FORMAT_BYTES
-
class W_AbstractBytesObject(W_Root):
__slots__ = ()
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -499,6 +499,8 @@
# ----------
+HASH_ALGORITHM = "rpython" # XXX Is there a better name?
+
def _hash_string(s):
"""The algorithm behind compute_hash() for a string or a unicode."""
from rpython.rlib.rarithmetic import intmask
More information about the pypy-commit
mailing list