[pypy-svn] r68368 - pypy/branch/gc-hash/pypy/objspace/std
arigo at codespeak.net
arigo at codespeak.net
Tue Oct 13 13:15:38 CEST 2009
Author: arigo
Date: Tue Oct 13 13:15:37 2009
New Revision: 68368
Modified:
pypy/branch/gc-hash/pypy/objspace/std/stringobject.py
pypy/branch/gc-hash/pypy/objspace/std/unicodeobject.py
Log:
Fix stringobject.
Modified: pypy/branch/gc-hash/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/branch/gc-hash/pypy/objspace/std/stringobject.py (original)
+++ pypy/branch/gc-hash/pypy/objspace/std/stringobject.py Tue Oct 13 13:15:37 2009
@@ -2,8 +2,8 @@
from pypy.objspace.std.objspace import *
from pypy.interpreter import gateway
-from pypy.rlib.rarithmetic import ovfcheck, _hash_string
-from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib.objectmodel import we_are_translated, compute_hash
from pypy.objspace.std.inttype import wrapint
from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
from pypy.objspace.std import slicetype
@@ -755,12 +755,7 @@
def hash__String(space, w_str):
s = w_str._value
- if we_are_translated():
- x = hash(s) # to use the hash cache in rpython strings
- else:
- x = _hash_string(s) # to make sure we get the same hash as rpython
- # (otherwise translation will freeze W_DictObjects where we can't find
- # the keys any more!)
+ x = compute_hash(s)
return wrapint(space, x)
def lt__String_String(space, w_str1, w_str2):
Modified: pypy/branch/gc-hash/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/branch/gc-hash/pypy/objspace/std/unicodeobject.py (original)
+++ pypy/branch/gc-hash/pypy/objspace/std/unicodeobject.py Tue Oct 13 13:15:37 2009
@@ -7,6 +7,7 @@
from pypy.objspace.std import slicetype
from pypy.objspace.std.tupleobject import W_TupleObject
from pypy.rlib.rarithmetic import intmask, ovfcheck
+from pypy.rlib.objectmodel import compute_hash
from pypy.module.unicodedata import unicodedb_4_1_0 as unicodedb
from pypy.tool.sourcetools import func_with_new_name
@@ -211,13 +212,7 @@
x ^= ord(s[0])
h = intmask(x)
return space.wrap(h)
- if we_are_translated():
- x = hash(s) # to use the hash cache in rpython strings
- else:
- from pypy.rlib.rarithmetic import _hash_string
- x = _hash_string(s) # to make sure we get the same hash as rpython
- # (otherwise translation will freeze W_DictObjects where we can't find
- # the keys any more!)
+ x = compute_hash(s)
return space.wrap(x)
def len__Unicode(space, w_uni):
More information about the Pypy-commit
mailing list