0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 11:15:56 +01:00

Sped intersection by large factors (3-5x faster than before on sets of

cardinality 500; and the smaller the intersection, the bigger the speedup).
This commit is contained in:
Tim Peters 2002-08-25 19:12:45 +00:00
parent 4a2f91e302
commit d33e6be59d

View File

@ -176,13 +176,8 @@ class BaseSet(object):
little, big = self, other
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
common = filter(big._data.has_key, little._data.iterkeys())
return self.__class__(common)
def intersection(self, other):
"""Return the intersection of two sets as a new set.