Author: Maciej Fijalkowski <[email protected]>
Branch: rdict-experiments-3
Changeset: r67306:e4d96795fc24
Date: 2013-10-11 11:20 +0200
http://bitbucket.org/pypy/pypy/changeset/e4d96795fc24/
Log: remove force_non_null flag, not used any more
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -296,13 +296,12 @@
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):
"""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)
+ dictdef = DictDef(self, is_r_dict=is_r_dict)
self.dictdefs[self.position_key] = dictdef
return dictdef
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -287,14 +287,8 @@
clsdef = clsdef.commonbase(cdef)
return SomeInstance(clsdef)
-def robjmodel_r_dict(s_eqfn, s_hashfn, s_force_non_null=None):
- if s_force_non_null is None:
- force_non_null = False
- else:
- assert s_force_non_null.is_constant()
- force_non_null = s_force_non_null.const
- dictdef = getbookkeeper().getdictdef(is_r_dict=True,
- force_non_null=force_non_null)
+def robjmodel_r_dict(s_eqfn, s_hashfn):
+ dictdef = getbookkeeper().getdictdef(is_r_dict=True)
dictdef.dictkey.update_rdict_annotations(s_eqfn, s_hashfn)
return SomeDict(dictdef)
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -628,11 +628,10 @@
The functions key_eq() and key_hash() are used by the key comparison
algorithm."""
- def __init__(self, key_eq, key_hash, force_non_null=False):
+ def __init__(self, key_eq, key_hash):
self._dict = {}
self.key_eq = key_eq
self.key_hash = key_hash
- self.force_non_null = force_non_null
def __getitem__(self, key):
return self._dict[_r_dictkey(self, key)]
diff --git a/rpython/rtyper/lltypesystem/rdict.py
b/rpython/rtyper/lltypesystem/rdict.py
--- a/rpython/rtyper/lltypesystem/rdict.py
+++ b/rpython/rtyper/lltypesystem/rdict.py
@@ -174,7 +174,7 @@
class DictRepr(AbstractDictRepr):
def __init__(self, rtyper, key_repr, value_repr, dictkey, dictvalue,
- custom_eq_hash=None, force_non_null=False):
+ custom_eq_hash=None):
self.rtyper = rtyper
self.DICT = lltype.GcForwardReference()
self.lowleveltype = lltype.Ptr(self.DICT)
@@ -193,7 +193,6 @@
self.dictvalue = dictvalue
self.dict_cache = {}
self._custom_eq_hash_repr = custom_eq_hash
- self.force_non_null = force_non_null
# setup() needs to be called to finish this initialization
def _externalvsinternal(self, rtyper, item_repr):
@@ -212,7 +211,6 @@
# able to store dummy values
s_key = self.dictkey.s_value
s_value = self.dictvalue.s_value
- assert not self.force_non_null # XXX kill the flag
kwd = {}
if self.custom_eq_hash:
self.r_rdict_eqfn, self.r_rdict_hashfn = (
@@ -886,15 +884,12 @@
pass
-def rtype_r_dict(hop, i_force_non_null=None):
+def rtype_r_dict(hop):
r_dict = hop.r_result
if not r_dict.custom_eq_hash:
raise TyperError("r_dict() call does not return an r_dict instance")
v_eqfn = hop.inputarg(r_dict.r_rdict_eqfn, arg=0)
v_hashfn = hop.inputarg(r_dict.r_rdict_hashfn, arg=1)
- if i_force_non_null is not None:
- assert i_force_non_null == 2
- hop.inputarg(lltype.Void, arg=2)
cDICT = hop.inputconst(lltype.Void, r_dict.DICT)
hop.exception_cannot_occur()
v_result = hop.gendirectcall(ll_newdict, cDICT)
diff --git a/rpython/rtyper/rdict.py b/rpython/rtyper/rdict.py
--- a/rpython/rtyper/rdict.py
+++ b/rpython/rtyper/rdict.py
@@ -10,7 +10,6 @@
dictvalue = self.dictdef.dictvalue
s_key = dictkey.s_value
s_value = dictvalue.s_value
- force_non_null = self.dictdef.force_non_null
if dictkey.custom_eq_hash:
custom_eq_hash = lambda: (rtyper.getrepr(dictkey.s_rdict_eqfn),
rtyper.getrepr(dictkey.s_rdict_hashfn))
@@ -18,7 +17,7 @@
custom_eq_hash = None
return DictRepr(rtyper, lambda: rtyper.getrepr(s_key),
lambda: rtyper.getrepr(s_value), dictkey, dictvalue,
- custom_eq_hash, force_non_null)
+ custom_eq_hash)
def rtyper_makekey(self):
self.dictdef.dictkey .dont_change_any_more = True
diff --git a/rpython/rtyper/test/test_rdict.py
b/rpython/rtyper/test/test_rdict.py
--- a/rpython/rtyper/test/test_rdict.py
+++ b/rpython/rtyper/test/test_rdict.py
@@ -1264,25 +1264,6 @@
res = f()
assert res == 1
- def test_nonnull_hint(self):
- def eq(a, b):
- return a == b
- def rhash(a):
- return 3
-
- def func(i):
- d = r_dict(eq, rhash, force_non_null=True)
- if not i:
- d[None] = i
- else:
- d[str(i)] = i
- return "12" in d, d
-
- llres = self.interpret(func, [12])
- assert llres.item0 == 1
- DICT = lltype.typeOf(llres.item1)
- assert sorted(DICT.TO.entries.TO.OF._flds) == ['f_hash', 'key',
'value']
-
def test_memoryerror_should_not_insert(self):
# This shows a misbehaviour that also exists in CPython 2.7, but not
# any more in CPython 3.3. The behaviour is that even if a dict
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit