Looks like it was available here <a href="http://docs.cython.org/docs/language_basics.html#integer-for-loops">http://docs.cython.org/docs/language_basics.html#integer-for-loops</a> and <a href="http://docs.cython.org/docs/pyrex_differences.html#automatic-range-conversion">http://docs.cython.org/docs/pyrex_differences.html#automatic-range-conversion</a><br>
<br><div class="gmail_quote">On Wed, Mar 18, 2009 at 10:23 PM, Anoop Saldanha <span dir="ltr">&lt;<a href="mailto:poonaatsoc@gmail.com">poonaatsoc@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks Kurt.  That was helpful.  Looks like the optimization is happening at IterationTransform() in the pipeline.<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Wed, Mar 18, 2009 at 9:59 PM, Kurt Smith <span dir="ltr">&lt;<a href="mailto:kwmsmith@gmail.com" target="_blank">kwmsmith@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">2009/3/18 Anoop Saldanha &lt;<a href="mailto:poonaatsoc@gmail.com" target="_blank">poonaatsoc@gmail.com</a>&gt;:<br>


<br>
[snip]<br>
<div><br>
&gt;<br>
&gt; But<br>
&gt;<br>
&gt; cdef int g():<br>
&gt;      print &quot;g called&quot;<br>
&gt;      return 5<br>
&gt;<br>
&gt; def f():<br>
&gt;     cdef int i<br>
&gt;     for i in range(g()):<br>
&gt;         print i<br>
&gt;     print i<br>
&gt;<br>
&gt; uses a ForFromStatNode for the &quot;for in&quot; loop!<br>
<br>
</div>I&#39;m not a core developer, so this is open to correction, but putting<br>
in some PrintTree() calls into<br>
Cython/Compiler/Main.py:create_pipeline() shows that it starts out as<br>
a ForInStatNode and is changed to a ForFromStatNode.  Perhaps because<br>
cython inferrs that g returns a C int and it triggers the &#39;range&#39;<br>
optimization.<br>
<br>
Before any transformations:<br>
<br>
- (root): ModuleNode(pos=(foo.pyx:1:0))<br>
  - body: StatListNode(pos=(foo.pyx:1:0))<br>
    - stats[0]: CFuncDefNode(pos=(foo.pyx:1:5))<br>
     [removing cdef int g() stuff]<br>
    - stats[1]: DefNode(name=&quot;f&quot;)<br>
      - body: StatListNode(pos=(foo.pyx:6:4))<br>
        - stats[0]: CVarDefNode(pos=(foo.pyx:6:9))<br>
          - base_type: CSimpleBaseTypeNode(pos=(foo.pyx:6:9))<br>
          - declarators[0]: CNameDeclaratorNode(pos=(foo.pyx:6:13))<br>
        - stats[1]: ForInStatNode(pos=(foo.pyx:8:4)) &lt;== starts out as<br>
as ForInStatNode<br>
          [snip rest of def f() function body]<br>
<br>
After all transformations:<br>
<br>
- (root): ModuleNode(pos=(foo.pyx:1:0))<br>
  - body: StatListNode(pos=(foo.pyx:1:0))<br>
    - stats[0]: CFuncDefNode(pos=(foo.pyx:1:5))<br>
       [snip func body]<br>
    - stats[1]: DefNode(name=&quot;f&quot;)<br>
      - body: StatListNode(pos=(foo.pyx:6:4))<br>
        - stats[0]: ForFromStatNode(pos=(foo.pyx:8:4))  &lt;== Changed to<br>
a ForFromStatNode.<br>
          - target: NameNode(type=&lt;CNumericType int&gt;, name=&quot;i&quot;)<br>
          - bound1: IntNode(type=&lt;CNumericType long&gt;)<br>
          - bound2: SimpleCallNode(type=&lt;CNumericType int&gt;)<br>
            - function: NameNode(type=&lt;CFuncType &lt;CNumericType int&gt;<br>
[]&gt;, name=&quot;g&quot;)<br>
          - step: IntNode(type=&lt;CNumericType long&gt;)<br>
          - body: StatListNode(pos=(foo.pyx:9:8))<br>
            - stats[0]: PrintStatNode(pos=(foo.pyx:9:8))<br>
              - arg_tuple: TupleNode(type=&lt;PyTuple_Type&gt;)<br>
                - args[0]: CoerceToPyTypeNode(type=&lt;PyObjectType&gt;)<br>
                  - arg: NameNode(type=&lt;CNumericType int&gt;, name=&quot;i&quot;)<br>
        - stats[1]: PrintStatNode(pos=(foo.pyx:10:4))<br>
          - arg_tuple: TupleNode(type=&lt;PyTuple_Type&gt;)<br>
            - args[0]: CoerceToPyTypeNode(type=&lt;PyObjectType&gt;)<br>
              - arg: NameNode(type=&lt;CNumericType int&gt;, name=&quot;i&quot;)<br>
<font color="#888888"><br>
Kurt<br>
</font><div><div></div><div>_______________________________________________<br>
Cython-dev mailing list<br>
<a href="mailto:Cython-dev@codespeak.net" target="_blank">Cython-dev@codespeak.net</a><br>
<a href="http://codespeak.net/mailman/listinfo/cython-dev" target="_blank">http://codespeak.net/mailman/listinfo/cython-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br></div></div><div><div></div><div class="h5">-- <br>Regards,<br>Anoop S.<br><br>People who says, &quot;It&#39;s not winning or losing that matters, but participation&quot;, probably lost.<br>

</div></div></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Anoop S.<br><br>People who says, &quot;It&#39;s not winning or losing that matters, but participation&quot;, probably lost.<br>