[pypy-commit] pypy set-strategies: added different method for symmetric_difference_update when strategies match

l.diekmann noreply at buildbot.pypy.org
Thu Nov 10 13:49:42 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49158:e4d6683b7917
Date: 2011-05-17 13:39 +0200
http://bitbucket.org/pypy/pypy/changeset/e4d6683b7917/

Log:	added different method for symmetric_difference_update when
	strategies match

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -422,7 +422,23 @@
                 result.add(w_key)
         return result
 
+    def symmetric_difference_update_match(self, w_set, w_other):
+        d_new = self.get_empty_dict()
+        d_this = self.cast_from_void_star(w_set.sstorage)
+        d_other = self.cast_from_void_star(w_other.sstorage)
+        for key in d_other.keys():
+            if not key in d_this:
+                d_new[key] = None
+        for key in d_this.keys():
+            if not key in d_other:
+                d_new[key] = None
+
+        w_set.sstorage = self.cast_to_void_star(d_new)
+
     def symmetric_difference_update(self, w_set, w_other):
+        if w_set.strategy is w_other.strategy:
+            self.symmetric_difference_update_match(w_set, w_other)
+            return
         #XXX no wrapping when strategies are equal
         newsetdata = newset(self.space)
         for w_key in w_set.getkeys():


More information about the pypy-commit mailing list