title: While True or while 1?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3815359/while-1-vs-for-whiletrue-why-is-there-a-difference">while (1) Vs. for while(True) &mdash; Why is there a difference?</a>  </p>
  </blockquote>
  
  
  
  <p>I see sometimes in other people code "while 1" instead of "while True".
  I think using True is more pythonic, but I wanted to check if there is
  any difference in practice.</p>
  
  <p>So I tried to do the following, and the result is surprising.  For what
  I can see it looks like the interpreter can optimize away the 1 boolean
  conversion while it doesn't with the True, the opposite of what I
  supposed.</p>
  
  <p>Anyone can explain me why is that, or maybe is my conclusion wrong?</p>
  
  <pre><code>def f1():
      while 1:
          pass
  
  def f2():
      while True:
          pass
  
  In [10]: dis.dis(f)
  2           0 SETUP_LOOP               3 (to 6)
  
  3     &gt;&gt;    3 JUMP_ABSOLUTE            3
        &gt;&gt;    6 LOAD_CONST               0 (None)
              9 RETURN_VALUE
  
  In [9]: dis.dis(f1)
  2           0 SETUP_LOOP              10 (to 13)
        &gt;&gt;    3 LOAD_GLOBAL              0 (True)
              6 POP_JUMP_IF_FALSE       12
  
  3           9 JUMP_ABSOLUTE            3
        &gt;&gt;   12 POP_BLOCK
        &gt;&gt;   13 LOAD_CONST               0 (None)
             16 RETURN_VALUE
  </code></pre>