[pypycommit] pypy setstrategies: refactored symmetric_difference for sets
l.diekmann
noreply at buildbot.pypy.org
Thu Nov 10 13:51:18 CET 2011
Author: Lukas Diekmann <lukas.diekmann at uniduesseldorf.de>
Branch: setstrategies
Changeset: r49205:3e0b4ff1c77a
Date: 20111004 13:53 +0200
http://bitbucket.org/pypy/pypy/changeset/3e0b4ff1c77a/
Log: refactored symmetric_difference for sets
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
@@ 457,23 +457,21 @@
strategy = self.space.fromcache(ObjectSetStrategy)
return strategy.cast_to_void_star(newsetdata)
 def symmetric_difference(self, w_set, w_other):
+ def _symmetric_difference_base(self, w_set, w_other):
if w_set.strategy is w_other.strategy:
strategy = w_set.strategy
storage = self._symmetric_difference_unwrapped(w_set, w_other)
else:
strategy = self.space.fromcache(ObjectSetStrategy)
storage = self._symmetric_difference_wrapped(w_set, w_other)
+ return storage, strategy
+
+ def symmetric_difference(self, w_set, w_other):
+ storage, strategy = self._symmetric_difference_base(w_set, w_other)
return w_set.from_storage_and_strategy(storage, strategy)
def symmetric_difference_update(self, w_set, w_other):
 if w_set.strategy is w_other.strategy:
 strategy = w_set.strategy
 storage = self._symmetric_difference_unwrapped(w_set, w_other)
 else:
 strategy = self.space.fromcache(ObjectSetStrategy)
 storage = self._symmetric_difference_wrapped(w_set, w_other)

+ storage, strategy = self._symmetric_difference_base(w_set, w_other)
w_set.strategy = strategy
w_set.sstorage = storage
More information about the pypycommit
mailing list