I'm trying to write a function to remov duplicates in a list without sorting, but it take long time in big lists, Is there a faster way than this?
from time import time
def delrepeat(rlist):
ti = time()
repeated = []
for i in list(set(rlist)):
rc = rlist.count(i)
if rc > 1:
repeated.append((i, rc))
newlist = list(reversed(rlist))
for repeat in repeated:
i, rc = repeat
while rc > 1:
newlist.pop(newlist.index(i))
rc -= 1
print(time()-ti)
return list(reversed(newlist))
delrepeat([3,2,1,3,5,3]*10000)
# --------------------------
# 5.181169271469116
# [3, 2, 1, 5]