Removing dupes from a list
Cliff Wells
logiplexsoftware at earthlink.net
Fri Apr 26 17:58:51 EDT 2002
On Fri, 26 Apr 2002 14:03:08 -0700
Cliff Wells wrote:
> def de_dup(liste):
> dups = filter(lambda i: liste.count(i) > 1, liste)
> return [i for i in liste if i not in dups]
>
> >>> l = [[1,2,3],[1,2,3],[4,5],[1,2],[1,2,3], 1, 2, 3, 4, 2]
> >>> de_dup(l)
> [[4, 5], [1, 2], 1, 3, 4]
> >>>
>
> I expect the list.count() will be a performance killer on large lists.
And I expect this will also be the wrong answer as it removes *all* of the
duplicates :P
Er, is there any chance that no one saw this?
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308
More information about the Python-list
mailing list