P
Paul
Can anyone suggest an efficient way to eliminate duplicate entries
in a list? The naive approach below works fine, but is very slow
with lists containing tens of thousands of entries:
def uniq(list):
u = []
for x in list:
if x not in u: u.append(x)
return u
print uniq(['a','b','c','a'])
['a', 'b', 'c']
Thanks,
-- Paul
in a list? The naive approach below works fine, but is very slow
with lists containing tens of thousands of entries:
def uniq(list):
u = []
for x in list:
if x not in u: u.append(x)
return u
print uniq(['a','b','c','a'])
['a', 'b', 'c']
Thanks,
-- Paul