title: Select an element that satisfies a condition
body: <p>I would like to select a specific element that satisfies a condition from a (very long) list. In my specific case each item in the list is a class and the condition I want is, for example, item.id == 1. </p>
  
  <p>I started with</p>
  
  <pre><code>[item for item in collection if item.id == 1]
  </code></pre>
  
  <p>but I don't want to traverse the whole list because I am sure there is only one element that satisfied the condition.</p>
  
  <p>The other option is</p>
  
  <pre><code>def check(collection):
      for item in collection:
          if item.id == 1:
              return item
  </code></pre>
  
  <p>Is there a more efficient way? Does Python 3 have a build in function for that?
  Another option could be to preprocess the list in order to obtain a dictionary, e.g.</p>
  
  <pre><code>{item.id : item for item in collection}
  </code></pre>