[pypy-commit] pypy remove-set-smm: Remove set.__i*__ multi-methods.

Manuel Jacob noreply at buildbot.pypy.org
Wed May 15 14:01:12 CEST 2013


Author: Manuel Jacob
Branch: remove-set-smm
Changeset: r64138:47b6699cda78
Date: 2013-05-15 11:44 +0200
http://bitbucket.org/pypy/pypy/changeset/47b6699cda78/

Log:	Remove set.__i*__ multi-methods.

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
@@ -263,6 +263,22 @@
     def descr_xor(self, space, w_other):
         return self.symmetric_difference(w_other)
 
+    def descr_inplace_sub(self, space, w_other):
+        self.difference_update(w_other)
+        return self
+
+    def descr_inplace_and(self, space, w_other):
+        self.intersect_update(w_other)
+        return self
+
+    def descr_inplace_or(self, space, w_other):
+        self.update(w_other)
+        return self
+
+    def descr_inplace_xor(self, space, w_other):
+        self.descr_symmetric_difference_update(space, w_other)
+        return self
+
     def descr_copy(self, space):
         """Return a shallow copy of a set."""
         if type(self) is W_FrozensetObject:
@@ -478,6 +494,12 @@
     __or__ = gateway.interp2app(W_BaseSetObject.descr_or),
     __xor__ = gateway.interp2app(W_BaseSetObject.descr_xor),
 
+    # mutating operators
+    __isub__ = gateway.interp2app(W_BaseSetObject.descr_inplace_sub),
+    __iand__ = gateway.interp2app(W_BaseSetObject.descr_inplace_and),
+    __ior__ = gateway.interp2app(W_BaseSetObject.descr_inplace_or),
+    __ixor__ = gateway.interp2app(W_BaseSetObject.descr_inplace_xor),
+
     # non-mutating methods
     __reduce__ = gateway.interp2app(W_BaseSetObject.descr_reduce),
     copy = gateway.interp2app(W_BaseSetObject.descr_copy),
@@ -1491,18 +1513,6 @@
     else:
         return None
 
-def inplace_or__Set_Set(space, self, w_other):
-    self.update(w_other)
-    return self
-
-inplace_or__Set_Frozenset = inplace_or__Set_Set
-
-def inplace_sub__Set_Set(space, self, w_other):
-    self.difference_update(w_other)
-    return self
-
-inplace_sub__Set_Frozenset = inplace_sub__Set_Set
-
 def _discard_from_set(space, w_left, w_item):
     """
     Discard an element from a set, with automatic conversion to
@@ -1524,18 +1534,6 @@
         w_left.switch_to_empty_strategy()
     return deleted
 
-def inplace_and__Set_Set(space, self, w_other):
-    self.intersect_update(w_other)
-    return self
-
-inplace_and__Set_Frozenset = inplace_and__Set_Set
-
-def inplace_xor__Set_Set(space, self, w_other):
-    self.descr_symmetric_difference_update(space, w_other)
-    return self
-
-inplace_xor__Set_Frozenset = inplace_xor__Set_Set
-
 def cmp__Set_settypedef(space, self, w_other):
     # hack hack until we get the expected result
     raise OperationError(space.w_TypeError,


More information about the pypy-commit mailing list