title: Python unique list using set
body: <p>What I am trying to do is write a method that takes a list as an argument and uses a set to return a copy of the list where each element only occurs once, as well as having the elements in the new list occur in order of their first occurrence in the original list. I HAVE to use a set for this, however, I can't make it so that the output is in the right order while having a quick result.
  If I put something like this:</p>
  <pre><code>def unique(a):
  
  return list(set(a))
  </code></pre>
  <p>and passed a list with millions of elements, it would give me a result quickly, but it wouldn't be ordered.
  So what I have right now is this:</p>
  <pre><code>def unique(a):
  b = set(a)
  c = {}
  d = []
  for i in b:
      c[a.index(i)] = i
  for i in c:
      d.append(c[i])
  return d
  </code></pre>
  <p>This gives me the result I want, but not fast enough. If I pass a list with a million elements, I could be waiting for half an hour, whereas the one liner up there takes less than a second. How could I solve this problem?</p>