imbosol at aerojockey.invalid
Thu Dec 18 12:26:49 CET 2003
Paul Rubin wrote:
> "Greg Ewing (using news.cis.dfn.de)" <g2h5dqi002 at sneakemail.com> writes:
>> In this case, evaluating the default args at call time would
>> have a negative payoff, since it would slow down every call to
>> the function in cases where the default value doesn't need
>> to be evaluated more than once.
> In those cases the compiler should notice it and generate appropriate
> code to evaluate the default arg just once. In many of the cases it
> can put a static value into the .pyc file.
In a perfect world, that would be a good way to do it. However,
Python is NOT in the business of deciding whether an arbitrary object
is constant or not, except maybe in the parsing stages. Internally,
it's just not built that way.
If I were designing, I would definitely make it the language's (and
extension writers') business, because there is a lot of opportunity
CARL BANKS http://www.aerojockey.com/software
"If you believe in yourself, drink your school, stay on drugs, and
don't do milk, you can get work."
-- Parody of Mr. T from a Robert Smigel Cartoon
More information about the Python-list