Get indexes for first occurrence of each element in a list?
<p>I have a list of about 90k elements (about 670 unique). I would like to get the indexes for the first occurrence of each value. I have just tried a list comprehension like this:</p>

<pre><code>In: [["foo", "bar", "baz", "bar", "foo"].index(x) for x in ["foo", "bar", "baz", "bar", "foo"]]
Out: [0, 1, 2, 1, 0]
</code></pre>

<p>This works, but it takes a couple of minutes to run on my machine. What is a better (faster) way to do this?</p>