[Python-ideas] New 3.x restriction on number of keyword arguments (original) (raw)

Cesare Di Mauro cesare.di.mauro at gmail.com
Tue Oct 26 22:30:16 CEST 2010


2010/10/26 Antoine Pitrou <solipsis at pitrou.net>

On Tue, 26 Oct 2010 19:22:32 +0200 Cesare Di Mauro <cesare.di.mauro at gmail.com> wrote: > > At this time I have no other ideas to solve this problem. > > Please, let me know if there's interest on a new patch to implement the > "compiler-based" solution.

Have you timed the EXTENDEDARG solution? Regards Antoine.

I made some a few minutes ago, and the results are unbelievable and counter-intuitive on my machine (Athlon64 2800+ socket 754, 2GB DDR 400, Windows 7 x64, Python 3.2a3 32 bits running at high priority):

python.exe -m timeit -r 1 -n 100000000 -s "def f(): pass" "f()" Standard : 100000000 loops, best of 1: 0.348 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 0.341 usec per loop

python.exe -m timeit -r 1 -n 100000000 -s "def f(x, y, z): pass" "f(1, 2, 3)" Standard : 100000000 loops, best of 1: 0.452 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 0.451 usec per loop

python.exe -m timeit -r 1 -n 100000000 -s "def f(a = 1, b = 2, c = 3): pass" "f(a = 1, b = 2, c = 3)" Standard : 100000000 loops, best of 1: 0.578 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 0.556 usec per loop

python.exe -m timeit -r 1 -n 100000000 -s "def f(x, y, z, a = 1, b = 2, c = 3): pass" "f(1, 2, 3, a = 1, b = 2, c = 3)" Standard : 100000000 loops, best of 1: 0.761 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 0.739 usec per loop

python.exe -m timeit -r 1 -n 100000000 -s "def f(*Args): pass" "f(1, 2, 3)" Standard : 100000000 loops, best of 1: 0.511 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 0.508 usec per loop

python.exe -m timeit -r 1 -n 100000000 -s "def f(**Keys): pass" "f(a = 1, b = 2, c = 3)" Standard : 100000000 loops, best of 1: 0.789 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 0.784 usec per loop

python.exe -m timeit -r 1 -n 100000000 -s "def f(*Args, **Keys): pass" "f(1, 2, 3, a = 1, b = 2, c = 3)" Standard : 100000000 loops, best of 1: 1.01 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 1.01 usec per loop

python.exe -m timeit -r 1 -n 100000000 -s "def f(*Args, **Keys): pass" "f()" Standard : 100000000 loops, best of 1: 0.393 usec per loop EXTENDED_ARG: 100000000 loops, best of 1: 0.41 usec per loop

I really can't explain it. Ouch!

Cesare -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20101026/7799ee55/attachment.html>



More information about the Python-ideas mailing list