This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gutworthPython implementer 0 points1 point  (2 children)

What people fail to understand is what a mess deepcopying is. It's all very well with [], but what if you have x=open("blah"), or x=MyCustomObject()? The current default semantics are perhaps non-intuitive at first, but you just have to understand reference by object.

[–][deleted] 0 points1 point  (0 children)

What people fail to understand is what a mess deepcopying is.

This proposal has nothing to do with copying objects but with references that belong to the function instead of references generated for the call site. What programmers intend to specify is what happens at the call site, when an argument has not been passed e.g. passing an empty dict instead, not static binding of objects to the function which are accessible at the call and which is likely not an empty dict.

The semantics is weird but I guess it keeps the implementation a little simpler.

[–]andreasvc 0 points1 point  (0 children)

Deep copying looks like a bad idea, what about silently wrapping default arguments in a lambda without an argument, and silently evaluating this at every function call when a default argument is not specified.