[Python-ideas] Uniquify attribute for lists
p.f.moore at gmail.com
Fri Nov 16 13:39:48 CET 2012
On 16 November 2012 12:28, Robrecht De Rouck <de.rouck.robrecht at gmail.com>wrote:
> I just wanted to bring to your attention that an *attribute for removing
> duplicate elements* for lists would be a nice feature.
> *def uniquify(lis):
> seen = set()
> seen_add = seen.add
> return [ x for x in lis if x not in seen and not seen_add(x)]*
> The code is from this post<http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order>. Also
> check out this performance comparison<http://www.peterbe.com/plog/uniqifiers-benchmark> of
> uniquifying snippets.
> It would be useful to have a uniquify attribute for containers in general.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas