On Aug 7, 4:53 pm, kj no.em...@please.post wrote:
Suppose that x is some list. To produce a version of the list with
duplicate elements removed one could, I suppose, do this:
x = list(set(x))
but I expect that this will not preserve the original order of
elements.
I suppose that I
kj wrote:
I suppose that I could write something like
def uniquify(items):
seen = set()
ret = []
for i in items:
if not i in seen:
ret.append(i)
seen.add(i)
return ret
But this seems to me like such a commonly needed operation that I
find it hard to
On Aug 7, 4:53 pm, kj no.em...@please.post wrote:
Suppose that x is some list. To produce a version of the list with
duplicate elements removed one could, I suppose, do this:
x = list(set(x))
but I expect that this will not preserve the original order of
elements.
OrderedSet is most
Dennis Lee Bieber wlfr...@ix.netcom.com writes:
Why bother with seen?
The version with seen runs in linear time because of the O(1) set
lookup. Your version runs in quadratic time.
--
http://mail.python.org/mailman/listinfo/python-list
Suppose that x is some list. To produce a version of the list with
duplicate elements removed one could, I suppose, do this:
x = list(set(x))
but I expect that this will not preserve the original order of
elements.
I suppose that I could write something like
def uniquify(items):
On Aug 7, 1:53 pm, kj no.em...@please.post wrote:
Suppose that x is some list. To produce a version of the list with
duplicate elements removed one could, I suppose, do this:
x = list(set(x))
but I expect that this will not preserve the original order of
elements.
I suppose that I
En Fri, 07 Aug 2009 17:53:10 -0300, kj no.em...@please.post escribió:
Suppose that x is some list. To produce a version of the list with
duplicate elements removed one could, I suppose, do this:
x = list(set(x))
but I expect that this will not preserve the original order of
elements.
I