Re: Uniquifying a list?

2006-04-22 Thread Lawrence D'Oliveiro
In article [EMAIL PROTECTED], Felipe Almeida Lessa [EMAIL PROTECTED] wrote: list(set(x)) is the clear winner with almost O(1) performance. Moral: in an interpreted language, use builtins as much as possible. -- http://mail.python.org/mailman/listinfo/python-list

Re: Uniquifying a list?

2006-04-22 Thread bearophileHUGS
There is my version too: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438599 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Uniquifying a list?

2006-04-19 Thread Rene Pijlman
Tim Chase: Is there an obvious/pythonic way to remove duplicates from a list (resulting order doesn't matter, Use a set. http://www.python.org/doc/lib/types-set.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list

Uniquifying a list?

2006-04-18 Thread Tim Chase
Is there an obvious/pythonic way to remove duplicates from a list (resulting order doesn't matter, or can be sorted postfacto)? My first-pass hack was something of the form myList = [3,1,4,1,5,9,2,6,5,3,5] uniq = dict([k,None for k in myList).keys() or alternatively uniq =

Re: Uniquifying a list?

2006-04-18 Thread Felipe Almeida Lessa
Em Ter, 2006-04-18 às 10:31 -0500, Tim Chase escreveu: Is there an obvious/pythonic way to remove duplicates from a list (resulting order doesn't matter, or can be sorted postfacto)? My first-pass hack was something of the form myList = [3,1,4,1,5,9,2,6,5,3,5] uniq = dict([k,None for

Re: Uniquifying a list?

2006-04-18 Thread Edward Elliott
You could do uniq = [x for x in set(myList)] but that's not really any different than what you already have. This almost works: uniq = [x for x in myList if x not in uniq] except the r-val uniq isn't updated after each iteration. Personally I think list(set(myList)) is as optimal as

Re: Uniquifying a list?

2006-04-18 Thread Ben Finney
Tim Chase [EMAIL PROTECTED] writes: Is there an obvious/pythonic way to remove duplicates from a list (resulting order doesn't matter, or can be sorted postfacto)? My first-pass hack was something of the form myList = [3,1,4,1,5,9,2,6,5,3,5] uniq = dict([k,None for k in

Re: Uniquifying a list?

2006-04-18 Thread John Machin
On 19/04/2006 1:31 AM, Tim Chase wrote: Is there an obvious/pythonic way to remove duplicates from a list (resulting order doesn't matter, or can be sorted postfacto)? Google is your friend: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560 --