[Python-ideas] New 3.x restriction on number of keyword arguments
M.-A. Lemburg
mal at egenix.com
Tue Oct 26 23:46:38 CEST 2010
Cesare Di Mauro wrote:
> 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 EXTENDED_ARG 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!
Looks like a good solution to the problem - no performance
loss and a much higher limit on the number of arguments.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Oct 26 2010)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-ideas
mailing list