[Python-Dev] performance of {} versus dict()
Stefan Behnel
stefan_ml at behnel.de
Thu Nov 15 08:22:57 CET 2012
Chris Withers, 15.11.2012 08:14:
> On 15/11/2012 06:32, Stefan Behnel wrote:
>> 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.
>
> Agreed, but Donald, please try with a bunch of keys rather than an empty
> dict...
Right. If that makes a difference, it's another bug.
Stefan
More information about the Python-Dev
mailing list