filter list fast

lars_woetmann larswp at gmail.com
Sat Mar 18 16:45:11 EST 2006


comparing
[x for x in list1 if x not in list2]
with
set1, set2 = set(list1), set(list2)
list(set1-set2)

gives something like
len(list2)     speedup
------------------------------
100            10
1000          100
10000        1000

the speedup is constant for different len(list1)




More information about the Python-list mailing list