Lukas Diekmann avatar Lukas Diekmann committed 41bcb41

added fastpath for issubset and isdisjoint

Comments (0)

Files changed (2)

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)
 

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])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.