Commit 0ef6feb8 authored by Tim Peters's avatar Tim Peters

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

cardinality 500; and the smaller the intersection, the bigger the speedup).
parent a9795445
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment