On Wed, Feb 2, 2011 at 15:07, Jacob Hallén <ja...@openend.se> wrote:
> onsdag 02 februari 2011 03.09.09 skrev Łukasz Ligowski:
>>
>> I'd like to ask are there any rules of thumb to write code that PyPy JIT
>> can easily optimize? Or maybe which constructs are hardly optimizable by
>> JIT so it's better to avoid them?
>
> If you want absolutely best performance, write your code in a simple, straight
> forward way, trying to keep your most used loops free of branches.
>
> if a:
> for x in range(big number):
> calculate something
> else:
> for x in range(big number):
> calculate something else
>
> generates better code than
>
> for x in range(big number):
> if a:
> calculate something
> else:
> caculate something else
>
> In the second case, there will be a guard inside the loop that has to be
> evaluated every time through.
Is there a plan to automate this optimization, or are there problems
to extend it to tracing JIT compilation? I think the standard name is
code hoisting and other compilers do it.
--
Paolo Giarrusso - Ph.D. Student
http://www.informatik.uni-marburg.de/~pgiarrusso/
_______________________________________________
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev