<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    (Enormous hand-waving over significant details below)<br>
    <br>
    If your code is this:<br>
    <br>
    &nbsp;&nbsp;&nbsp; 10:&nbsp;&nbsp;&nbsp; for item in container:<br>
    &nbsp;&nbsp;&nbsp; 11:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if item.some_condition() or item.some_other():<br>
    &nbsp;&nbsp;&nbsp; 12:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; continue<br>
    &nbsp;&nbsp;&nbsp; 13:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; item.do_real_stuff()<br>
    <br>
    Then the generated code looks very crudely something like:<br>
    <br>
    &nbsp;&nbsp;&nbsp; 10a:&nbsp;&nbsp;&nbsp; start iterating container<br>
    &nbsp;&nbsp;&nbsp; 10b:&nbsp;&nbsp;&nbsp; get next item<br>
    &nbsp;&nbsp;&nbsp; 11a:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if item.some_condition() jump to 12a<br>
    &nbsp;&nbsp;&nbsp; 11b:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if item.some_other() jump to 12a<br>
    &nbsp;&nbsp;&nbsp; 11c:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; jump to 13a<br>
    &nbsp;&nbsp;&nbsp; 12a:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; jump to 10b<br>
    &nbsp;&nbsp;&nbsp; 13a:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; item.do_real_stuff()<br>
    &nbsp;&nbsp;&nbsp; 13b:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; jump to 10b<br>
    <br>
    The peephole optimizer sees that lines 11a and 11b include a jump to
    12a, but 12a is an unconditional jump to 10b, so it changes line 11a
    and 11b:<br>
    <br>
    &nbsp;&nbsp;&nbsp; 11a:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if item.some_condition() jump to 10b<br>
    &nbsp;&nbsp;&nbsp; 11b:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if item.some_other() jump to 10b<br>
    <br>
    Line 12 is now never executed.<br>
    <br>
    --Ned.<br>
    <br>
    <br>
    On 7/3/2011 9:09 AM, Eric Henry wrote:
    <blockquote
cite="mid:CAJS6nNN1KSgj=OpWY8yfWmFncTVMjbViBChiUk6QL9O4Xo34mw@mail.gmail.com"
      type="cite">Right, but the point is that you're not doing anything
      else if the condition is true.
      <div><br>
      </div>
      <div>I can't say for sure, but it would seem that it could easily
        convert the if ... continue into a "branch on equal" type
        bytecode. What happens if you have a print statement before the
        continue?<br>
        <div><br clear="all">
          Eric<br>
          <br>
          <br>
          <div class="gmail_quote">On Sun, Jul 3, 2011 at 6:41 AM,
            Laurens Van Houtven <span dir="ltr"><a class="moz-txt-link-rfc2396E" href="mailto:_@lvh.cc">&lt;_@lvh.cc&gt;</a></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
              0.8ex; border-left: 1px solid rgb(204, 204, 204);
              padding-left: 1ex;">
              Hang on. This appears to be for *unconditional* jumps. My
              jump isn't unconditional, it's "if snr is None or prn is
              None:". How does that get optimized away? Where's the
              always-true condition? "prn is None or snr is None" is
              certainly not always true, in fact, that's the exception,
              not the norm.<br>
              <br>
              _______________________________________________<br>
              testing-in-python mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
              <a moz-do-not-send="true"
                href="http://lists.idyll.org/listinfo/testing-in-python"
                target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
  </body>
</html>