title: Why is sys.path a list?
body: <p>Why would the implementers choose to make <code>sys.path</code> into a list as opposed to a ordered set?</p>
  
  <p>Having <code>sys.path</code> as a list gives rise to the possibility of having multiple duplicates in the path, slowing down the search time for modules.</p>
  
  <p>An artificial example would be the following silly example</p>
  
  <pre><code># instant importing
  import os
  import sys
  
  for i in xrange(50000):
      sys.path.insert(0, os.path.abspath(".")
  
  # importing takes a while to fail
  import hello
  </code></pre>
  
  <p>To summarise from the comments and answers given:</p>
  
  <p>It seems from the responses below that a list is a simple structure which handles 99% of everyone's needs, it does not come with a safety feature of avoiding duplicates however it does come with a primitive prioritisation which is the index of the element in the list where you can easily set the highest priority by prepending or lowest priority by appending.</p>
  
  <p>Adding a richer prioritisation i.e. insert before this element would be rarely used as the interface to this would be too much effort for a simple task. As the accepted answer states, there is no practical need for anything more advanced covering these extra use cases as historically people are used to this.</p>