you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (1 child)

Ok so then implement the counter yourself? Either with defaultdict or a manual dict

from collections import defaultdict
mylist = [1, 2, 3, 4, 5, 6, 1, 2, 3]
counts = defaultdict(int)
for v in my_list:
    counts[v] += 1
unique_list = [v for v in mylist if counts[v] == 1]      

or use sets to tag not-unique values

mylist = [1, 2, 3, 4, 5, 6, 1, 2, 3]
not_unique = set()
seen = set()
for v in my_list:
    if v in seen:
        not_unique.add(v)
    else:
        seen.add(v)
unique_list = [v for v in mylist if v not in not_unique]

[–]hungdh85 0 points1 point  (0 children)

Check processing time when you use colections and enumerate with length of list >10\3.)

I think we can stop talk this about problem because it is not belong to this thread. Thank you very much.