[pypy-commit] pypy py3.5-siphash24: Fix the parameters in sys.hash_info
arigo
pypy.commits at gmail.com
Mon Jan 30 11:15:03 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5-siphash24
Changeset: r89842:26fb67149ae5
Date: 2017-01-30 17:12 +0100
http://bitbucket.org/pypy/pypy/changeset/26fb67149ae5/
Log: Fix the parameters in sys.hash_info
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,7 +5,6 @@
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
@@ -79,11 +78,22 @@
return space.call_function(w_int_info, space.newtuple(info_w))
def get_hash_info(space):
- HASH_HASH_BITS = 8 * rffi.sizeof(lltype.Signed)
- HASH_SEED_BITS = 0 # XXX don't know what this is supposed to be
+ HASH_ALGORITHM = space.config.objspace.hash
+ if space.config.objspace.hash == "fnv":
+ HASH_HASH_BITS = 8 * rffi.sizeof(lltype.Signed)
+ HASH_SEED_BITS = 0
+ # CPython has ^ > 0 here, but the seed of "fnv" is of limited
+ # use, so we don't implement it
+ elif space.config.objspace.hash == "siphash24":
+ HASH_HASH_BITS = 64
+ HASH_SEED_BITS = 128
+ else:
+ assert 0, "please add the parameters for this different hash function"
+
+ HASH_WIDTH = 8 * rffi.sizeof(lltype.Signed)
HASH_CUTOFF = 0
info_w = [
- space.wrap(8 * rffi.sizeof(lltype.Signed)),
+ space.wrap(HASH_WIDTH),
space.wrap(HASH_MODULUS),
space.wrap(HASH_INF),
space.wrap(HASH_NAN),
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 import jit
from rpython.rlib.objectmodel import (
compute_hash, compute_unique_id, import_from_mixin, newlist_hint,
- resizelist_hint, HASH_ALGORITHM)
+ resizelist_hint)
from rpython.rlib.buffer import StringBuffer
from rpython.rlib.rstring import StringBuilder
More information about the pypy-commit
mailing list