aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2017-12-11 17:38:14 +0100
committerCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2017-12-11 17:38:14 +0100
commit83903b76378b0bd97497e9eb3b5e35524208ce35 (patch)
tree20088a7e1070b306f311bbc4eaf680e540236fb7 /rpython/annotator
parentexplain what the arguments mean (diff)
downloadpypy-83903b76378b0bd97497e9eb3b5e35524208ce35.tar.gz
pypy-83903b76378b0bd97497e9eb3b5e35524208ce35.tar.bz2
pypy-83903b76378b0bd97497e9eb3b5e35524208ce35.zip
thread the fast_hash info through the various layers into the rordereddict
implementation
Diffstat (limited to 'rpython/annotator')
-rw-r--r--rpython/annotator/bookkeeper.py5
-rw-r--r--rpython/annotator/builtin.py19
-rw-r--r--rpython/annotator/dictdef.py4
3 files changed, 17 insertions, 11 deletions
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
index 4139ee91af..38acb2708a 100644
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -194,13 +194,14 @@ class Bookkeeper(object):
listdef.generalize_range_step(flags['range_step'])
return SomeList(listdef)
- def getdictdef(self, is_r_dict=False, force_non_null=False):
+ def getdictdef(self, is_r_dict=False, force_non_null=False, fast_hash=False):
"""Get the DictDef associated with the current position."""
try:
dictdef = self.dictdefs[self.position_key]
except KeyError:
dictdef = DictDef(self, is_r_dict=is_r_dict,
- force_non_null=force_non_null)
+ force_non_null=force_non_null,
+ fast_hash=fast_hash)
self.dictdefs[self.position_key] = dictdef
return dictdef
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
index 82fd2161f4..844ec544a7 100644
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -238,6 +238,14 @@ def robjmodel_instantiate(s_clspbc, s_nonmovable=None):
@analyzer_for(rpython.rlib.objectmodel.r_dict)
def robjmodel_r_dict(s_eqfn, s_hashfn, s_force_non_null=None, s_fast_hash=None):
+ return _r_dict_helper(SomeDict, s_eqfn, s_hashfn, s_force_non_null, s_fast_hash)
+
+@analyzer_for(rpython.rlib.objectmodel.r_ordereddict)
+def robjmodel_r_ordereddict(s_eqfn, s_hashfn, s_force_non_null=None, s_fast_hash=None):
+ return _r_dict_helper(SomeOrderedDict, s_eqfn, s_hashfn,
+ s_force_non_null, s_fast_hash)
+
+def _r_dict_helper(cls, s_eqfn, s_hashfn, s_force_non_null, s_fast_hash):
if s_force_non_null is None:
force_non_null = False
else:
@@ -249,15 +257,10 @@ def robjmodel_r_dict(s_eqfn, s_hashfn, s_force_non_null=None, s_fast_hash=None):
assert s_fast_hash.is_constant()
fast_hash = s_fast_hash.const
dictdef = getbookkeeper().getdictdef(is_r_dict=True,
- force_non_null=force_non_null)
- dictdef.dictkey.update_rdict_annotations(s_eqfn, s_hashfn)
- return SomeDict(dictdef)
-
-@analyzer_for(rpython.rlib.objectmodel.r_ordereddict)
-def robjmodel_r_ordereddict(s_eqfn, s_hashfn):
- dictdef = getbookkeeper().getdictdef(is_r_dict=True)
+ force_non_null=force_non_null,
+ fast_hash=fast_hash)
dictdef.dictkey.update_rdict_annotations(s_eqfn, s_hashfn)
- return SomeOrderedDict(dictdef)
+ return cls(dictdef)
@analyzer_for(rpython.rlib.objectmodel.hlinvoke)
def robjmodel_hlinvoke(s_repr, s_llcallable, *args_s):
diff --git a/rpython/annotator/dictdef.py b/rpython/annotator/dictdef.py
index 656ef83864..d6558973ba 100644
--- a/rpython/annotator/dictdef.py
+++ b/rpython/annotator/dictdef.py
@@ -81,12 +81,14 @@ class DictDef(object):
def __init__(self, bookkeeper, s_key = s_ImpossibleValue,
s_value = s_ImpossibleValue,
is_r_dict = False,
- force_non_null = False):
+ force_non_null = False,
+ fast_hash = False):
self.dictkey = DictKey(bookkeeper, s_key, is_r_dict)
self.dictkey.itemof[self] = True
self.dictvalue = DictValue(bookkeeper, s_value)
self.dictvalue.itemof[self] = True
self.force_non_null = force_non_null
+ self.fast_hash = fast_hash
def read_key(self, position_key):
self.dictkey.read_locations.add(position_key)