⬅︎ Back to Fastest way to uniqify a list in Python
I tried optimizing the top competitors:* f8 5.239* f8b 4.415 <--* f8c 4.971* f11 5.692* f11b 4.882* f11c 4.713 <--* f12 5.76* f12b 4.911 <--f12 is Mike Watkins' function.f8b, f11b, f12b is unchanged except for storing a reference to seen.add/uniq.removef8c also tried to store a reference to seen.__contains__, which back-fired.In f11c I tried to change if-continue-statements to if-not-statements, as Anonymous sugested.Optimizing attribute lookup can give 15% speedup.Removing continue statements can give another 5%.Changing the in-operator to a call to __contains__ removes 10%.
Comment
I tried optimizing the top competitors:
* f8 5.239
* f8b 4.415 <--
* f8c 4.971
* f11 5.692
* f11b 4.882
* f11c 4.713 <--
* f12 5.76
* f12b 4.911 <--
f12 is Mike Watkins' function.
f8b, f11b, f12b is unchanged except for storing a reference to seen.add/uniq.remove
f8c also tried to store a reference to seen.__contains__, which back-fired.
In f11c I tried to change if-continue-statements to if-not-statements, as Anonymous sugested.
Optimizing attribute lookup can give 15% speedup.
Removing continue statements can give another 5%.
Changing the in-operator to a call to __contains__ removes 10%.