[Python-Dev] performance of {} versus dict()
Stefan Behnel
stefan_ml at behnel.de
Thu Nov 15 07:32:41 CET 2012
Donald Stufft, 15.11.2012 00:00:
> $ pypy -m timeit 'dict()'
> 1000000000 loops, best of 3: 0.000811 usec per loop
>
> $ pypy -m timeit '{}'
> 1000000000 loops, best of 3: 0.000809 usec per loop
>
> $ pypy -m timeit 'def md(**kw): return kw; md()'
> 100000000 loops, best of 3: 0.0182 usec per loop
>
> $ pypy -m timeit -s 'def md(**kw): return kw' 'md()'
> 1000000000 loops, best of 3: 0.00136 usec per loop
Yep, I really like the fact that optimisers can fold stupid benchmarks into
no-ops. I wonder why it fails so badly in the latter two cases, though. You
should bring that to the attention of the PyPy developers, they might want
to fix it.
Stefan
More information about the Python-Dev
mailing list