[pypy-svn] r68459 - in pypy/branch/gc-hash/pypy: interpreter module/__builtin__
arigo at codespeak.net
arigo at codespeak.net
Wed Oct 14 18:52:33 CEST 2009
Author: arigo
Date: Wed Oct 14 18:52:32 2009
New Revision: 68459
Modified:
pypy/branch/gc-hash/pypy/interpreter/buffer.py
pypy/branch/gc-hash/pypy/interpreter/pycode.py
pypy/branch/gc-hash/pypy/interpreter/typedef.py
pypy/branch/gc-hash/pypy/module/__builtin__/interp_classobj.py
Log:
More usages of hash().
Modified: pypy/branch/gc-hash/pypy/interpreter/buffer.py
==============================================================================
--- pypy/branch/gc-hash/pypy/interpreter/buffer.py (original)
+++ pypy/branch/gc-hash/pypy/interpreter/buffer.py Wed Oct 14 18:52:32 2009
@@ -19,6 +19,7 @@
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.gateway import interp2app, ObjSpace, W_Root
from pypy.interpreter.error import OperationError
+from pypy.rlib.objectmodel import compute_hash
class Buffer(Wrappable):
@@ -117,7 +118,7 @@
descr_ge = _make_descr__cmp('ge')
def descr_hash(self, space):
- return space.wrap(hash(self.as_str()))
+ return space.wrap(compute_hash(self.as_str()))
descr_hash.unwrap_spec = ['self', ObjSpace]
def descr_mul(self, space, w_times):
Modified: pypy/branch/gc-hash/pypy/interpreter/pycode.py
==============================================================================
--- pypy/branch/gc-hash/pypy/interpreter/pycode.py (original)
+++ pypy/branch/gc-hash/pypy/interpreter/pycode.py Wed Oct 14 18:52:32 2009
@@ -13,6 +13,7 @@
from pypy.rlib.rarithmetic import intmask
from pypy.rlib.debug import make_sure_not_resized, make_sure_not_modified
from pypy.rlib import jit
+from pypy.rlib.objectmodel import compute_hash
# helper
@@ -300,15 +301,15 @@
def descr_code__hash__(self):
space = self.space
- result = hash(self.co_name)
+ result = compute_hash(self.co_name)
result ^= self.co_argcount
result ^= self.co_nlocals
result ^= self.co_flags
result ^= self.co_firstlineno
- result ^= hash(self.co_code)
- for name in self.co_varnames: result ^= hash(name)
- for name in self.co_freevars: result ^= hash(name)
- for name in self.co_cellvars: result ^= hash(name)
+ result ^= compute_hash(self.co_code)
+ for name in self.co_varnames: result ^= compute_hash(name)
+ for name in self.co_freevars: result ^= compute_hash(name)
+ for name in self.co_cellvars: result ^= compute_hash(name)
w_result = space.wrap(intmask(result))
for w_name in self.co_names_w:
w_result = space.xor(w_result, space.hash(w_name))
Modified: pypy/branch/gc-hash/pypy/interpreter/typedef.py
==============================================================================
--- pypy/branch/gc-hash/pypy/interpreter/typedef.py (original)
+++ pypy/branch/gc-hash/pypy/interpreter/typedef.py Wed Oct 14 18:52:32 2009
@@ -10,7 +10,6 @@
from pypy.interpreter.error import OperationError
from pypy.tool.sourcetools import compile2, func_with_new_name
from pypy.rlib.objectmodel import instantiate, compute_identity_hash
-from pypy.rlib.rarithmetic import intmask
from pypy.rlib.jit import hint
class TypeDef:
@@ -48,8 +47,7 @@
# Hash support
def default_identity_hash(space, w_obj):
- hash = compute_identity_hash(w_obj)
- return space.wrap(intmask(hash))
+ return space.wrap(compute_identity_hash(w_obj))
def descr__hash__unhashable(space, w_obj):
typename = space.type(w_obj).getname(space, '?')
Modified: pypy/branch/gc-hash/pypy/module/__builtin__/interp_classobj.py
==============================================================================
--- pypy/branch/gc-hash/pypy/module/__builtin__/interp_classobj.py (original)
+++ pypy/branch/gc-hash/pypy/module/__builtin__/interp_classobj.py Wed Oct 14 18:52:32 2009
@@ -6,6 +6,7 @@
from pypy.interpreter.argument import Arguments
from pypy.interpreter.baseobjspace import Wrappable
from pypy.rlib.rarithmetic import r_uint, intmask
+from pypy.rlib.objectmodel import compute_identity_hash
def raise_type_err(space, argument, expected, w_obj):
@@ -569,7 +570,7 @@
raise OperationError(space.w_TypeError,
space.wrap("unhashable instance"))
else:
- return space.wrap(hash(self))
+ return space.wrap(compute_identity_hash(self))
w_ret = space.call_function(w_func)
if (not space.is_true(space.isinstance(w_ret, space.w_int)) and
not space.is_true(space.isinstance(w_ret, space.w_long))):
More information about the Pypy-commit
mailing list