On Jan 1, 2008 12:26 AM, NickC <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Jan 1, 3:22 am, Arnaud Delobelle <<a href="mailto:arno...@googlemail.com">arno...@googlemail.com</a>> wrote:<br>> On Dec 31, 10:58 am, Odalrick <<a href="mailto:odalr...@hotmail.com">odalr...@hotmail.com
</a>> wrote:<br>><br></div><div class="Ih2E3d">> > I'm surprised noone has said anything about the why of default<br>> > mutables. I think it is becasue it isn't easy to do it an other way.<br>>
<br>> [...]<br>><br>> There is an easy enough way: evaluate default values when the function<br>> is called rather than when it is defined.  This behaviour comes with<br>> its own caveats as well I imagine, and it's not 'as easy' to implement
<br>> as the current one.<br><br></div>As Odalrick notes, there is no way to give different calls to a<br>function their own copies of mutable default arguments without re-<br>evaluating the defaults every time the function is called.
</blockquote><div><br>There's a policy solution: stipulate that default arguments must be immutable (or hashable, as Python prefers to call it).<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The<br>horrendous performance implications mean that that simply isn't going<br>to happen. </blockquote><div><br>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?
<br><br>-- <br>Neil Cerutti<br> </div></div><br>