[Python-checkins] python/dist/src/Lib sets.py,1.23,1.24
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 25 Aug 2002 12:12:47 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv1102/python/lib
Modified Files:
sets.py
Log Message:
Sped intersection by large factors (3-5x faster than before on sets of
cardinality 500; and the smaller the intersection, the bigger the speedup).
Index: sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** sets.py 25 Aug 2002 18:59:04 -0000 1.23
--- sets.py 25 Aug 2002 19:12:45 -0000 1.24
***************
*** 177,187 ****
else:
little, big = other, self
! result = self.__class__()
! data = result._data
! value = True
! for elt in little:
! if elt in big:
! data[elt] = value
! return result
def intersection(self, other):
--- 177,182 ----
else:
little, big = other, self
! common = filter(big._data.has_key, little._data.iterkeys())
! return self.__class__(common)
def intersection(self, other):