timeit.timeit('a = range(50);b=range(25, 75);set(a)&set(b)') # takes about 5 seconds timeit.timeit('a = range(50);b=range(25, 75);[x for x in a if x in b]') # takes about 15 seconds