Default parameters
Paul Rubin
http
Thu Dec 18 09:39:07 EST 2003
Carl Banks <imbosol at aerojockey.invalid> writes:
> Consider something like this:
>
> def func(param=((1,2),(3,4),(5,6),(7,8))):
> whatever
>
> Do you really want to be building a big-ass nested tuple every time
> the function is called?
Come on, the compiler can easily recognize that that list is constant.
> Python evaluates default args at time of definition mostly for
> performance reasons (and maybe so we could simulate closures before we
> had real closures). My gut feeling is, moving the evaluation to call
> time would be too much of a performance hit to justify it.
Python takes so many other performance hits for the sake of
convenience and/or clarity that this particular one would be miniscule
by comparison.
More information about the Python-list
mailing list