In Python, what is the fastest algorithm for removing duplicates from a list so that all elements ar
Posted
by Jeff Miller
on Stack Overflow
See other posts from Stack Overflow
or by Jeff Miller
Published on 2008-09-18T01:25:21Z
Indexed on
2010/04/09
13:13 UTC
Read the original article
Hit count: 286
For example:
>>> x = [1, 1, 2, 'a', 'a', 3]
>>> unique(x)
[1, 2, 'a', 3]
Assume list elements are hashable.
Clarification: The result should keep the first duplicate in the list. For example, [1, 2, 3, 2, 3, 1] becomes [1, 2, 3].
© Stack Overflow or respective owner