On 2012-11-14, at 23:43 , Chris Withers wrote: > On 14/11/2012 22:37, Chris Withers wrote: >> On 14/11/2012 10:11, mar...@v.loewis.de wrote: >>> def xdict(**kwds): >>> return kwds >> >> Hah, good call, this trumps both of the other options: >> >> $ python2.7 -m timeit -n 1000000 -r 5 -v >> "{'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7}" >> raw times: 1.45 1.45 1.44 1.45 1.45 >> 1000000 loops, best of 5: 1.44 usec per loop >> $ python2.6 -m timeit -n 1000000 -r 5 -v >> 'dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7)' >> raw times: 2.37 2.36 2.36 2.37 2.37 >> 1000000 loops, best of 5: 2.36 usec per loop$ python2.6 -m timeit -n >> 1000000 -r 5 -v 'def md(**kw): return kw; md(a=1,b=2,c=3,d=4,e=5,f=6,g=7)' >> raw times: 0.548 0.533 0.55 0.577 0.539 >> 1000000 loops, best of 5: 0.533 usec per loop > > Before anyone shoots me, yes, wrong python for two of them: > > $ python2.7 -m timeit -n 1000000 -r 5 -v > "{'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7}" > raw times: 1.49 1.49 1.5 1.49 1.48 > 1000000 loops, best of 5: 1.48 usec per loop > > $ python2.7 -m timeit -n 1000000 -r 5 -v 'dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7)' > raw times: 2.35 2.36 2.41 2.42 2.35 > 1000000 loops, best of 5: 2.35 usec per loop > > $ python2.7 -m timeit -n 1000000 -r 5 -v 'def md(**kw): return kw; > md(a=1,b=2,c=3,d=4,e=5,f=6,g=7)' > raw times: 0.507 0.515 0.516 0.529 0.524 > 1000000 loops, best of 5: 0.507 usec per loop
The last one is kind-of weird, it seems to be greatly advantaged by the local lookup: > python2.7 -m timeit -n 1000000 -r 5 -v > "{'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7}" raw times: 0.676 0.683 0.682 0.698 0.691 1000000 loops, best of 5: 0.676 usec per loop > python2.7 -m timeit -n 1000000 -r 5 -v 'dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7)' > raw times: 1.64 1.66 1.4 1.44 1.44 1000000 loops, best of 5: 1.4 usec per loop > python2.7 -m timeit -n 1000000 -r 5 -v 'def md(**kw): return kw; > md(a=1,b=2,c=3,d=4,e=5,f=6,g=7)' raw times: 0.188 0.203 0.201 0.195 0.202 1000000 loops, best of 5: 0.188 usec per loop > python2.7 -m timeit -n 1000000 -r 5 -v -s 'def md(**kw): return kw' > 'md(a=1,b=2,c=3,d=4,e=5,f=6,g=7)' raw times: 0.871 0.864 0.863 0.889 0.871 1000000 loops, best of 5: 0.863 usec per loop _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com