drochom wrote: > i suppose this one is faster (but in most cases efficiency doesn't > matter) > >>>>def stable_unique(s): > > e = {} > ret = [] > for x in s: > if not e.has_key(x): > e[x] = 1 > ret.append(x) > return ret
I'll repeat Peter Otten's link to Tim Peters's recipe here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560/ Read the comments at the end, they talk about order-preserving lists. See Raymond Hettinger's response: def uniq(alist) # Fastest order preserving set = {} return [set.setdefault(e,e) for e in alist if e not in set] STeVe -- http://mail.python.org/mailman/listinfo/python-list