[pypy-commit] pypy default: merge

cfbolz noreply at buildbot.pypy.org
Thu Jul 11 22:34:23 CEST 2013


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: 
Changeset: r65357:198a48545f50
Date: 2013-07-11 22:32 +0200
http://bitbucket.org/pypy/pypy/changeset/198a48545f50/

Log:	merge

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
@@ -1039,15 +1039,18 @@
 
 
 def update1(space, w_dict, w_data):
-    if space.findattr(w_data, space.wrap("keys")) is None:
+    if isinstance(w_data, W_DictMultiObject):    # optimization case only
+        update1_dict_dict(space, w_dict, w_data)
+        return
+    w_method = space.findattr(w_data, space.wrap("keys"))
+    if w_method is None:
         # no 'keys' method, so we assume it is a sequence of pairs
-        update1_pairs(space, w_dict, w_data)
+        data_w = space.listview(w_data)
+        update1_pairs(space, w_dict, data_w)
     else:
-        if isinstance(w_data, W_DictMultiObject):    # optimization case only
-            update1_dict_dict(space, w_dict, w_data)
-        else:
-            # general case -- "for k in o.keys(): dict.__setitem__(d, k, o[k])"
-            update1_keys(space, w_dict, w_data)
+        # general case -- "for k in o.keys(): dict.__setitem__(d, k, o[k])"
+        data_w = space.listview(space.call_function(w_method))
+        update1_keys(space, w_dict, data_w)
 
 
 @jit.look_inside_iff(lambda space, w_dict, w_data:
@@ -1061,8 +1064,8 @@
         w_dict.setitem(w_key, w_value)
 
 
-def update1_pairs(space, w_dict, w_data):
-    for w_pair in space.listview(w_data):
+def update1_pairs(space, w_dict, data_w):
+    for w_pair in data_w:
         pair = space.fixedview(w_pair)
         if len(pair) != 2:
             raise OperationError(space.w_ValueError,
@@ -1071,9 +1074,8 @@
         w_dict.setitem(w_key, w_value)
 
 
-def update1_keys(space, w_dict, w_data):
-    w_keys = space.call_method(w_data, "keys")
-    for w_key in space.listview(w_keys):
+def update1_keys(space, w_dict, data_w):
+    for w_key in data_w:
         w_value = space.getitem(w_data, w_key)
         w_dict.setitem(w_key, w_value)
 


More information about the pypy-commit mailing list