Challenge supporting custom deepcopy with inheritance
Scott David Daniels
Scott.Daniels at Acm.Org
Mon Jun 1 14:13:22 EDT 2009
Michael H. Goldwasser wrote:
> Chris,
>
> Thanks for your well-written reply. Your analogy to the
> complexities of other special methods is well noted. I'll accept
> the "small price for flexibility" that you note, if necessary.
> However, I still desire a cleaner solution.
You seem to think that "deepcopy" is a well-defined concept. It is
not and cannot be. A copy that understands its own abstractions can
work, but sometimes a container is used as a simple abstraction, and
sometimes it is used as a container. The choice between the two is
not one of structure, but one of intent. A true deepcopy could
survive making a copy of the number 23, but might fail as it makes
a copy of None, True, or False. Certainly a dictionary might or
might not be copied, depending on how the dictionary is used.
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list