Author: Carl Friedrich Bolz <[email protected]>
Branch: dict-strategies
Changeset: r44496:b357e9f5b209
Date: 2011-05-26 13:42 +0200
http://bitbucket.org/pypy/pypy/changeset/b357e9f5b209/
Log: rename _is_sane_hash to _hashes_differently_than_string, which is
far more accurate.
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -4,7 +4,7 @@
speed up global lookups a lot."""
from pypy.objspace.std.dictmultiobject import IteratorImplementation
-from pypy.objspace.std.dictmultiobject import DictStrategy, _is_sane_hash
+from pypy.objspace.std.dictmultiobject import DictStrategy,
_hashes_differently_than_string
from pypy.objspace.std.dictmultiobject import ObjectDictStrategy
from pypy.rlib import jit, rerased
@@ -79,7 +79,7 @@
# maps to the same cell later (even if this cell no longer
# represents a key)
cell.invalidate()
- elif _is_sane_hash(space, w_key_type):
+ elif _hashes_differently_than_string(space, w_key_type):
raise KeyError
else:
self.switch_to_object_strategy(w_dict)
@@ -99,7 +99,7 @@
if space.is_w(w_lookup_type, space.w_str):
return self.getitem_str(w_dict, space.str_w(w_lookup))
- elif _is_sane_hash(space, w_lookup_type):
+ elif _hashes_differently_than_string(space, w_lookup_type):
return None
else:
self.switch_to_object_strategy(w_dict)
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -13,7 +13,7 @@
def _is_str(space, w_key):
return space.is_w(space.type(w_key), space.w_str)
-def _is_sane_hash(space, w_lookup_type):
+def _hashes_differently_than_string(space, w_lookup_type):
""" Handles the case of a non string key lookup.
Types that have a sane hash/eq function should allow us to return True
directly to signal that the key is not in the dict in any case.
@@ -314,8 +314,6 @@
if self.is_correct_type(w_key):
del self.unerase(w_dict.dstorage)[self.unwrap(w_key)]
return
- elif _is_sane_hash(space, w_key_type):
- raise KeyError
else:
self.switch_to_object_strategy(w_dict)
return w_dict.delitem(w_key)
@@ -331,8 +329,6 @@
if self.is_correct_type(w_key):
return self.unerase(w_dict.dstorage).get(self.unwrap(w_key), None)
- elif _is_sane_hash(space, space.type(w_key)):
- return None
else:
self.switch_to_object_strategy(w_dict)
return w_dict.getitem(w_key)
@@ -425,7 +421,7 @@
if self.is_correct_type(w_key):
return self.unerase(w_dict.dstorage).get(self.unwrap(w_key), None)
- elif _is_sane_hash(space, space.type(w_key)):
+ elif _hashes_differently_than_string(space, space.type(w_key)):
return None
else:
self.switch_to_object_strategy(w_dict)
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -6,7 +6,7 @@
from pypy.interpreter.baseobjspace import W_Root
from pypy.objspace.std.dictmultiobject import W_DictMultiObject, DictStrategy,
ObjectDictStrategy
from pypy.objspace.std.dictmultiobject import IteratorImplementation
-from pypy.objspace.std.dictmultiobject import _is_sane_hash
+from pypy.objspace.std.dictmultiobject import _hashes_differently_than_string
from pypy.objspace.std.objectobject import W_ObjectObject
from pypy.objspace.std.typeobject import TypeCell
@@ -600,7 +600,7 @@
w_lookup_type = space.type(w_lookup)
if space.is_w(w_lookup_type, space.w_str):
return self.getitem_str(w_dict, space.str_w(w_lookup))
- elif _is_sane_hash(space, w_lookup_type):
+ elif _hashes_differently_than_string(space, w_lookup_type):
return None
else:
self.switch_to_object_strategy(w_dict)
@@ -644,7 +644,7 @@
flag = w_obj.deldictvalue(space, w_key)
if not flag:
raise KeyError
- elif _is_sane_hash(space, w_key_type):
+ elif _hashes_differently_than_string(space, w_key_type):
raise KeyError
else:
self.switch_to_object_strategy(w_dict)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit