On Wed, Feb 2, 2011 at 9:07 AM, Jacob Hallén <[email protected]> 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. > > Jacob Hallén > _______________________________________________ > [email protected] > http://codespeak.net/mailman/listinfo/pypy-dev > If you happen to be doing numerical calculations using the array module instead of lists will help. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero
_______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
