[Python-Dev] performance of {} versus dict()
Chris Withers
chris at simplistix.co.uk
Thu Nov 15 08:14:42 CET 2012
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...
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
More information about the Python-Dev
mailing list