Thursday, September 19, 2019

Python List: Is this the best way to remove duplicates while preserving order?


Possible Duplicates:
How do you remove duplicates from a list in Python whilst preserving order?
Algorithm - How to delete duplicate elements in a list efficiently?







I've read a lot of methods for removing duplicates from a python list while preserving the order. All the methods appear to require the creation of a function/sub-routine, which I think is not very computationally efficient.
I came up with the following and I would like to know if this is the most computationally efficient method to do so?
(My usage for this has to be the most efficient possible due to the need to have fast response time.) Thanks



b=[x for i,x in enumerate(a) if i==a.index(x)]

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...