On Thu, Feb 11, 2021 at 12:56 PM J. Pic <j...@yourlabs.org> wrote: > > I just meant removing the whole "default value mutating" story, not removing > mutable variables. Really, I was wondering if there was a use case where this > actually turns to an advantage, in which case it would be a designed feature > rather than an undesirable side effect, which it seems to be. >
Right, I know you weren't asking about removing mutables altogether. But how would you remove "default value mutating"? Do you disallow any mutable values from being argument defaults? Because that's a huge category of values that are no longer available. Mutable defaults most certainly ARE used deliberately, although often it's more as a sort of "static variable" rather than actually a parameter. But it's common enough as an idiom that it can't be changed without breaking a lot of code. > Now I'm wondering if you have considered copy on write, to save the overhead > from copying every mutable default at every call when it is not necessary. > That's its own level of mess. The only way to move forward with this is something backward-compatible, which probably means an explicit request for late binding (or copying, which comes to much the same thing). But it needs an elegant syntax. The proposal lives or dies on that syntax, and so far, it's always died. ChrisA -- https://mail.python.org/mailman/listinfo/python-list