Tim Peters on speed!
tuttledon at hotmail.com
Sun Nov 11 19:09:57 CET 2001
Ok, now that I have your attention <wink>...
In studing Tim' recipe "Remove duplicates from a sequence"
Tim assigns the result back to the original list rather than a new list.
Was this done for performance or convenients? Is there a performance
penalty for using a second list?
t = list(s)
del t # move on to the next method
assert n > 0
last = t
lasti = i = 1
while i < n:
if t[i] != last:
t[lasti] = last = t[i]
lasti += 1
i += 1
More information about the Python-list