⬅︎ Back to Fastest way to uniqify a list in Python
Hello guys, the ordered variant can be even faster, if you change the condition:``` seen = set() return [x for x in seq if not (x in seen or seen.add(x))]```and another quite important optimization is to avoid __getattr__ call by storing the actual used function:``` seen = set() seen_add = seen.add return [x for x in seq if not (x in seen or seen_add(x))]```
Comment
Hello guys, the ordered variant can be even faster, if you change the condition:
```
seen = set()
return [x for x in seq if not (x in seen or seen.add(x))]
```
and another quite important optimization is to avoid __getattr__ call by storing the actual used function:
```
seen = set()
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))]
```