Performance problem with filtering

Gerhard Häring gh_pythonlist at gmx.de
Wed Mar 13 21:42:59 EST 2002


I have two lists of files (approx. 50000 entries). Now I want to have all the
entries of list b, that are not in list a. However, the primitive:

results = []
for entry in b:
    if entry not in a:
        results.append(entry)

is terribly slow. I mean *really* slow. Any recommendations on how to optimize
this? Wouldn't it be nice if I could simply do b.removeall(a)?

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 7.5 °C      Wind: 0.9 m/s




More information about the Python-list mailing list