[Python-Dev] Usage of += on strings in loops in stdlib

Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Feb 13 16:02:57 CET 2013


2013/2/13 Lennart Regebro <regebro at gmail.com>

> On Wed, Feb 13, 2013 at 3:27 PM, Amaury Forgeot d'Arc
> <amauryfa at gmail.com> wrote:
> > Yes, it's jitted.
>
> Admittedly, I have no idea in which cases the JIT kicks in, and what I
> should do to make that happen to make sure I have the best possible
> real-life test cases.
>

PyPy JIT kicks in only after 1000 iterations.
I usually use timeit.
It's funny to see how the "1000 loops" line is 5 times faster than the "100
loops":

$ ./pypy-c -m timeit -v -s "a,b,c,d='1234'" "'{}{}{}{}'.format(a,b,c,d)"
10 loops -> 2.19e-05 secs
100 loops -> 0.000122 secs
1000 loops -> 0.00601 secs
10000 loops -> 0.000363 secs
100000 loops -> 0.00528 secs
1000000 loops -> 0.0533 secs
10000000 loops -> 0.528 secs
raw times: 0.521 0.52 0.51
10000000 loops, best of 3: 0.051 usec per loop


-- 
Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/798dca4c/attachment.html>


More information about the Python-Dev mailing list