Best way to make a list unique?
Steven Bethard
steven.bethard at gmail.com
Tue Mar 8 17:55:08 EST 2005
Delaney, Timothy C (Timothy) wrote:
> This is actually one thing that Java 1.5 has that I'd like to see in
> Python - the LinkedHashSet and LinkedHashMap. Very useful data
> structures.
>
> For those who don't know, these implement a hash set/map which iterates
> in the order that the keys were first added to the set/map.
>
> Such a data structure is fairly simple to implement, and removing
> duplicates then becomes:
>
> unique = list(linkedset(orig))
>
> and you're guaranteed to maintain order.
>
> Implementing these is fairly simple.
Sounds like a good candidate for the collections module. Of course
someone will need to implement it. ;)
STeVe
More information about the Python-list
mailing list