<br><br><div class="gmail_quote">On Thu, Apr 14, 2011 at 10:56 AM, Antonio Cuni <span dir="ltr">&lt;<a href="mailto:anto.cuni@gmail.com">anto.cuni@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 14/04/11 16:44, Hakan Ardo wrote:<br>
&gt; Second though, that will recompile on every call, but if we cache the<br>
&gt; promote functions:<br>
&gt;<br>
&gt;     def main(n, promoters={}):<br>
&gt;         i, a = 0, 0<br>
&gt;         if n not in promoters:<br>
&gt;             exec &quot;&quot;&quot;def promote(n):<br>
&gt;                         assert n==%d&quot;&quot;&quot; % n<br>
&gt;             promoters[n] = promote<br>
&gt;         else:<br>
&gt;             promote = promoters[n]<br>
&gt;         while i &lt; n:<br>
&gt;             promote(n)<br>
&gt;             a += i+5<br>
&gt;             i += 1<br>
&gt;         return a<br>
&gt;<br>
&gt; we will actualy get rid of the extra ptr_eq and guard_false too...<br>
<br>
</div>wow, that&#39;s advanced... and without knowing the internals of the JIT, it<br>
really looks like black magic.<br>
<br>
While we are at it and if you have time/feel like, could you please have a<br>
look to test_zeropadded and test_circular in test_pypy_c_new? It&#39;s not clear<br>
to me what they are supposed to check (note that it&#39;s fine if you say &quot;they<br>
just check that the program works correctly&quot; :-)).<br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
<a href="mailto:pypy-dev@codespeak.net">pypy-dev@codespeak.net</a><br>
<a href="http://codespeak.net/mailman/listinfo/pypy-dev" target="_blank">http://codespeak.net/mailman/listinfo/pypy-dev</a><br>
</div></div></blockquote></div><br>The idea of a builtin app level promote is cool, I guess it should be smart and unbox primitives though.<br><br>Alex<br clear="all"><br>-- <br>&quot;I disapprove of what you say, but I will defend to the death your right to say it.&quot; -- Evelyn Beatrice Hall (summarizing Voltaire)<br>
&quot;The people&#39;s good is the highest law.&quot; -- Cicero<br><br>