[pypy-commit] pypy rpython-hash: Disable support for explicitly non-ordered, non-empty prebuilt dicts

arigo pypy.commits at gmail.com
Thu Jan 26 06:36:12 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: rpython-hash
Changeset: r89785:ab8402f0c677
Date: 2017-01-26 12:35 +0100
http://bitbucket.org/pypy/pypy/changeset/ab8402f0c677/

Log:	Disable support for explicitly non-ordered, non-empty prebuilt dicts

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
@@ -236,21 +236,14 @@
                 if self.r_rdict_hashfn.lowleveltype != lltype.Void:
                     l_fn = self.r_rdict_hashfn.convert_const(dictobj.key_hash)
                     l_dict.fnkeyhash = l_fn
-
-                for dictkeycontainer, dictvalue in dictobj._dict.items():
-                    llkey = r_key.convert_const(dictkeycontainer.key)
-                    llvalue = r_value.convert_const(dictvalue)
-                    ll_dict_insertclean(l_dict, llkey, llvalue,
-                                        dictkeycontainer.hash)
-                return l_dict
-
+                any_items = dictobj._dict.items()
             else:
-                for dictkey, dictvalue in dictobj.items():
-                    llkey = r_key.convert_const(dictkey)
-                    llvalue = r_value.convert_const(dictvalue)
-                    ll_dict_insertclean(l_dict, llkey, llvalue,
-                                        l_dict.keyhash(llkey))
-                return l_dict
+                any_items = dictobj.items()
+            if any_items:
+                raise TyperError("found a prebuilt, explicitly non-ordered, "
+                                 "non-empty dict.  it would require additional"
+                                 " support to rehash it at program start-up")
+            return l_dict
 
     def rtype_len(self, hop):
         v_dict, = hop.inputargs(self)


More information about the pypy-commit mailing list