On Tue, May 31, 2011 at 5:17 PM, Henry Olders <henry.old...@mcgill.ca> wrote:
> Clearly, making a copy within the function eliminates the possibility of the
> side effects caused by passing in mutable objects. Would having the
> compiler/interpreter do this automatically make python so much different?

Yes, it would make Python quite different. If suddenly you couldn't
pass a mutable object to a function to get it muted (that sounds
wrong), then code will break. Also, there's a fairly serious
performance penalty to copying everything when it's not necessary. As
has been suggested, you can specifically and deliberately cause this
effect for any function(s) you wish to "protect" in this way; there's
no need to change the language's fundamentals to do it.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to