I have a list say `l = [10,10,20,15,10,20]`. I want to assign each unique value a certain "index" to get `[1,1,2,3,1,2]`.

This is my code:

```
a = list(set(l))
res = [a.index(x) for x in l]

```

Which turns out to be very slow. 

`l` has 1M elements, and 100K unique elements. I have also tried map with lambda and sorting, which did not help. What is the ideal way to do this?