On Jan 1, 2008 12:26 AM, NickC <[EMAIL PROTECTED]> wrote: > On Jan 1, 3:22 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > On Dec 31, 10:58 am, Odalrick <[EMAIL PROTECTED]> wrote: > > > > > I'm surprised noone has said anything about the why of default > > > mutables. I think it is becasue it isn't easy to do it an other way. > > > > [...] > > > > There is an easy enough way: evaluate default values when the function > > is called rather than when it is defined. This behaviour comes with > > its own caveats as well I imagine, and it's not 'as easy' to implement > > as the current one. > > As Odalrick notes, there is no way to give different calls to a > function their own copies of mutable default arguments without re- > evaluating the defaults every time the function is called.
There's a policy solution: stipulate that default arguments must be immutable (or hashable, as Python prefers to call it). The > horrendous performance implications mean that that simply isn't going > to happen. Are the performance implications truly horrendous, though? Considering that the "poorly performing" solution seems to be the functionality that the uninformed expect, perhaps they *want* it to perform that way? -- Neil Cerutti
-- http://mail.python.org/mailman/listinfo/python-list