title: list and dictionary: which one is faster
body: <p>I have the following pieces of code doing the sorting of a list by swapping pairs of elements:</p>
  
  <pre><code># Complete the minimumSwaps function below.
  def minimumSwaps(arr):
      counter = 0
      val_2_indx = {val: arr.index(val) for val in arr}
      for indx, x in enumerate(arr):
          if x != indx+1:
              arr[indx] = indx+1
              s_indx = val_2_indx[indx+1]
              arr[s_indx] = x
  
              val_2_indx[indx+1] = indx
              val_2_indx[x] = s_indx
              counter += 1
      return counter
  
  def minimumSwaps(arr):
      temp = [0] * (len(arr) + 1)
      for pos, val in enumerate(arr):
          temp[val] = pos
      swaps = 0
      for i in range(len(arr)):
          if arr[i] != i+1:
              swaps += 1
              t = arr[i]
              arr[i] = i+1
              arr[temp[i+1]] = t
              temp[t] = temp[i+1]
              temp[i+1] = i
      return swaps
  </code></pre>
  
  <p>The second function works much faster than the first one. However, I was told that dictionary is faster than list. 
  What's the reason here?</p>