Author: Lukas Diekmann <[email protected]>
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():
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit