Commits

Lukas Diekmann  committed 41bcb41

added fastpath for issubset and isdisjoint

  • Participants
  • Parent commits a7b6365
  • Branches set-strategies

Comments (0)

Files changed (2)

File pypy/objspace/std/setobject.py

 
         if w_set.strategy is w_other.strategy:
             return self._issubset_unwrapped(w_set, w_other)
+        elif not w_set.strategy.may_contain_equal_elements(w_other.strategy):
+            return False
         else:
             return self._issubset_wrapped(w_set, w_other)
 
 
         if w_set.strategy is w_other.strategy:
             return self._isdisjoint_unwrapped(w_set, w_other)
+        elif not w_set.strategy.may_contain_equal_elements(w_other.strategy):
+            return True
         else:
             return self._isdisjoint_wrapped(w_set, w_other)
 

File pypy/objspace/std/test/test_setobject.py

         assert a.intersection(b) == set()
         assert b.intersection(a) == set()
 
+        a = set([1,2,3])
+        b = set(["a","b","c"])
+        assert not a.issubset(b)
+        assert not b.issubset(a)
+
+        a = set([1,2,3])
+        b = set(["a","b","c"])
+        assert a.isdisjoint(b)
+        assert b.isdisjoint(a)
+
     def test_empty_intersect(self):
         e = set()
         x = set([1,2,3])