[pypy-svn] r13929 - pypy/dist/pypy/rpython
arigo at codespeak.net
arigo at codespeak.net
Sun Jun 26 12:59:54 CEST 2005
Author: arigo
Date: Sun Jun 26 12:59:53 2005
New Revision: 13929
Modified:
pypy/dist/pypy/rpython/rconstantdict.py
Log:
Commented out the hash computation functions now that we only use
rconstantdict for integers.
Modified: pypy/dist/pypy/rpython/rconstantdict.py
==============================================================================
--- pypy/dist/pypy/rpython/rconstantdict.py (original)
+++ pypy/dist/pypy/rpython/rconstantdict.py Sun Jun 26 12:59:53 2005
@@ -61,20 +61,20 @@
self.dict_cache[key] = result
r_key = self.key_repr
r_value = self.value_repr
- hashcompute = self.get_key_hash_function()
+ #hashcompute = self.get_key_hash_function()
for dictkey, dictvalue in dictobj.items():
llkey = r_key.convert_const(dictkey)
llvalue = r_value.convert_const(dictvalue)
- ll_constantdict_setnewitem(result, llkey, llvalue, hashcompute)
+ ll_constantdict_setnewitem(result, llkey, llvalue)#,hashcompute)
return result
- def get_key_hash_function(self):
- if isinstance(self.key_repr, rmodel.IntegerRepr):
- return ll_hash_identity
- elif isinstance(self.key_repr, rmodel.CharRepr):
- return ll_hash_char
- else:
- raise TyperError("no easy hash function for %r" % (self.key_repr,))
+## def get_key_hash_function(self):
+## if isinstance(self.key_repr, rmodel.IntegerRepr):
+## return ll_hash_identity
+## elif isinstance(self.key_repr, rmodel.CharRepr):
+## return ll_hash_char
+## else:
+## raise TyperError("no easy hash function for %r" % (self.key_repr,))
def rtype_len(self, hop):
v_dict, = hop.inputargs(self)
@@ -92,17 +92,17 @@
def rtype_getitem((r_dict, r_key), hop):
v_dict, v_key = hop.inputargs(r_dict, r_dict.key_repr)
- hashcompute = r_dict.get_key_hash_function()
- chashcompute = hop.inputconst(lltype.Void, hashcompute)
- return hop.gendirectcall(ll_constantdict_getitem, v_dict, v_key,
- chashcompute)
+ #hashcompute = r_dict.get_key_hash_function()
+ #chashcompute = hop.inputconst(lltype.Void, hashcompute)
+ return hop.gendirectcall(ll_constantdict_getitem, v_dict, v_key)
+ #chashcompute)
def rtype_contains((r_dict, r_key), hop):
v_dict, v_key = hop.inputargs(r_dict, r_dict.key_repr)
- hashcompute = r_dict.get_key_hash_function()
- chashcompute = hop.inputconst(lltype.Void, hashcompute)
- return hop.gendirectcall(ll_constantdict_contains, v_dict, v_key,
- chashcompute)
+ #hashcompute = r_dict.get_key_hash_function()
+ #chashcompute = hop.inputconst(lltype.Void, hashcompute)
+ return hop.gendirectcall(ll_constantdict_contains, v_dict, v_key)
+ #chashcompute)
# ____________________________________________________________
#
@@ -113,19 +113,19 @@
def ll_constantdict_len(d):
return d.num_items
-def ll_constantdict_getitem(d, key, hashcompute):
- entry = ll_constantdict_lookup(d, key, hashcompute)
+def ll_constantdict_getitem(d, key):#, hashcompute):
+ entry = ll_constantdict_lookup(d, key)#, hashcompute)
if entry.valid:
return entry.value
else:
raise KeyError
-def ll_constantdict_contains(d, key, hashcompute):
- entry = ll_constantdict_lookup(d, key, hashcompute)
+def ll_constantdict_contains(d, key):#, hashcompute):
+ entry = ll_constantdict_lookup(d, key)#, hashcompute)
return entry.valid
-def ll_constantdict_setnewitem(d, key, value, hashcompute):
- entry = ll_constantdict_lookup(d, key, hashcompute)
+def ll_constantdict_setnewitem(d, key, value):#, hashcompute):
+ entry = ll_constantdict_lookup(d, key)#, hashcompute)
assert not entry.valid
entry.key = key
entry.valid = True
@@ -135,8 +135,8 @@
# the below is a port of CPython's dictobject.c's lookdict implementation
PERTURB_SHIFT = 5
-def ll_constantdict_lookup(d, key, hashcompute):
- hash = hashcompute(key)
+def ll_constantdict_lookup(d, key):#, hashcompute):
+ hash = key #hashcompute(key)
entries = d.entries
mask = len(entries) - 1
perturb = r_uint(hash)
@@ -150,8 +150,8 @@
perturb >>= PERTURB_SHIFT
i = (i << 2) + i + perturb + 1
-def ll_hash_identity(x):
- return x
+##def ll_hash_identity(x):
+## return x
-def ll_hash_char(x):
- return ord(x)
+##def ll_hash_char(x):
+## return ord(x)
More information about the Pypy-commit
mailing list