[pypy-commit] pypy unicode-utf8-py3: disable the fromkeys fast path, it's yet another way to get a non-ascii key

cfbolz pypy.commits at gmail.com
Sun Jan 13 09:09:44 EST 2019


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: unicode-utf8-py3
Changeset: r95625:0e7fd7135bc7
Date: 2019-01-12 23:16 +0100
http://bitbucket.org/pypy/pypy/changeset/0e7fd7135bc7/

Log:	disable the fromkeys fast path, it's yet another way to get a non-
	ascii key

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
@@ -122,17 +122,11 @@
         if w_fill is None:
             w_fill = space.w_None
         if space.is_w(w_type, space.w_dict):
-            ulist = space.listview_utf8(w_keys)
-            if ulist is not None:
-                strategy = space.fromcache(UnicodeDictStrategy)
-                storage = strategy.get_storage_fromkeys(ulist, w_fill)
-                w_dict = space.allocate_instance(W_DictObject, w_type)
-                W_DictObject.__init__(w_dict, space, strategy, storage)
-            else:
-                w_dict = W_DictMultiObject.allocate_and_init_instance(space,
-                                                                      w_type)
-                for w_key in space.listview(w_keys):
-                    w_dict.setitem(w_key, w_fill)
+            # XXX consider re-enabling a fast-path here
+            w_dict = W_DictMultiObject.allocate_and_init_instance(space,
+                                                                  w_type)
+            for w_key in space.listview(w_keys):
+                w_dict.setitem(w_key, w_fill)
         else:
             w_dict = space.call_function(w_type)
             for w_key in space.listview(w_keys):
@@ -1217,14 +1211,6 @@
             i += 1
         return keys, values
 
-    def get_storage_fromkeys(self, keys_w, w_fill):
-        """Return an initialized storage with keys and fill values"""
-        storage = {}
-        mark_dict_non_null(storage)
-        for key in keys_w:
-            storage[key] = w_fill
-        return self.erase(storage)
-
 create_iterator_classes(UnicodeDictStrategy)
 
 
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -125,6 +125,7 @@
         assert self.space.eq_w(space.call_function(get, w("33"), w(44)), w(44))
 
     def test_fromkeys_fastpath(self):
+        py.test.skip("doesn't make sense here")
         space = self.space
         w = space.wrap
 


More information about the pypy-commit mailing list