[Python-Dev] copy() and deepcopy()
Aahz
aahz at pythoncraft.com
Sat Nov 22 09:21:19 EST 2003
On Sat, Nov 22, 2003, Raymond Hettinger wrote:
>
> The point of a deepcopy is to replace each sub-component (at every
> nesting level) that could possibly change. Since sets can only contain
> hashable objects which in turn can only contain hashable objects, I
> surmise that a shallowcopy of a set would also suffice as its deepcopy.
Thing is, it *is* possible to have a mutable and hashable object. The
hashable part needs to be immutable, but not the rest. Consider dicts
in the generic sense: the key needs to be immutable, but the value need
not, and it certainly can be useful to combine key/value into a single
object.
Now, I'm still not sure that your analysis is wrong, but I wanted to be
very, very clear that hashability is not the same thing as immutability.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Weinberg's Second Law: If builders built buildings the way programmers wrote
programs, then the first woodpecker that came along would destroy civilization.
More information about the Python-Dev
mailing list