原文地址:http://www.peterbe.com/plog/uniqifiers-benchmark
Fastest way to uniqify a list in Python
Suppose you have a list in python that looks like this:
[
'a'
,
'b'
,
'a'
]
# or like this:
[ 1 , 2 , 2 , 2 , 3 , 4 , 5 , 6 , 6 , 6 , 6 ]
# or like this:
[ 1 , 2 , 2 , 2 , 3 , 4 , 5 , 6 , 6 , 6 , 6 ]
and you want to remove all duplicates so you get this result:
[
'a'
,
'b'
]
# or
[
1
,
2
,
3
,
4
,
5
,
6
]