[Python-checkins] python/dist/src/Lib sets.py,1.7,1.8

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Tue, 20 Aug 2002 19:22:10 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv15434

Modified Files:
	sets.py 
Log Message:
Fast size check for sub/super set tests

Index: sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** sets.py	21 Aug 2002 01:35:29 -0000	1.7
--- sets.py	21 Aug 2002 02:22:08 -0000	1.8
***************
*** 240,243 ****
--- 240,245 ----
          """Report whether another set contains this set."""
          self._binary_sanity_check(other)
+         if len(self) > len(other):  # Fast check for obvious cases
+             return False
          for elt in self:
              if elt not in other:
***************
*** 248,251 ****
--- 250,255 ----
          """Report whether this set contains another set."""
          self._binary_sanity_check(other)
+         if len(self) < len(other):  # Fast check for obvious cases
+             return False
          for elt in other:
              if elt not in self: