[Python-3000] Using a list for *args (was: Type annotations:annotating generators)

Collin Winter collinw at gmail.com
Fri Jun 2 18:05:40 CEST 2006


On 6/1/06, Michael Chermside <mcherm at mcherm.com> wrote:
> Collin Winter writes:
> > I've attached the benchmarks as a comment on the patch, but I'll
> > repeat them here. All times are usecs per loop.
>       [statistics showing list is about 15% slower]
>
> My memory is fuzzy here. Can someone repeat for me the reasons
> why we wanted to use list? Were we just trying it out to see how
> it worked, or was there a desire to change? Was the desire to
> change because it improved some uses of the C api, or was it
> just for "purity" in use of tuples vs lists?
>
> I'm not a "need for speed" kind of guy, but I can't remember what
> the advantages of the list approach were supposed to be.

The main reason (in my mind, at least) was tuple/list purity.

> By the way I'm curious about the following also:
>
> # interpolating a list (I presume there's no advantage, but just checking)
> ./python -mtimeit 'def foo(*args): pass' 'foo(*range(10))'
Tuple: 4.22
List: 4.57

> # calling a function that doesn't use *args
> ./python -mtimeit 'def foo(): pass' 'foo()'
Tuple: 1.5
List: 1.51

> ./python -mtimeit 'def foo(x): pass' 'foo(1)'
Tuple: 1.62
List: 1.59

> ./python -mtimeit 'def foo(x,y): pass' 'foo(1,2)'
Tuple: 1.7
List: 1.7

> ./python -mtimeit 'def foo(x,y,z): pass' 'foo(1,2,3)'
Tuple: 1.84
List: 1.83

Collin Winter


More information about the Python-3000 mailing list