title: Would it be better to use "if x in (y, z)" over "if x == y or x == z"?
body: <p>Given this simple condition:</p>
  
  <pre><code>if x == y or x == z:
      print("Hello World!");
  </code></pre>
  
  <p>I understand that Python would first look to see if <code>x</code> is equal to <code>y</code> and if <code>x</code> is <strong>not</strong> equal to <code>y</code> it then it would check to see if <code>x</code> is equal to <code>z</code>, printing <code>Hello World!</code> if at least one of the conditions is <code>True</code>.</p>
  
  <p>If I were to do this instead:</p>
  
  <pre><code>if x in (y, z):
      print("Hello World!");
  </code></pre>
  
  <p>To my understanding Python would iterate through the "yz" tuple and then print <code>Hello World!</code> if the value of <code>x</code> is in the "yz" tuple.</p>
  
  <p>Which method would be faster / more efficient to use?<br />
  Would Python not bother to check if <code>x</code> was equal to <code>z</code> if <code>x</code> was equal to <code>y</code>?<br />
  Would Python still execute the code in the if statement if <code>x</code> was equal to <code>y</code> but <strong>not</strong> <code>z</code>?</p>
  
  <p>Thank you in advance.</p>