Elegant copy-by-value

Andrew Dalke adalke at mindspring.com
Mon Jan 13 21:06:28 CET 2003


Mel Wilson wrote:
>    It seems to me that TRT for deepcopy is the
> application-dependent feature from Hell.
> 
>    Say you have a dictionary of lists of class instances.
> How does a dictionary deepcopy method distinguish between
> list members that are shared-by-accident and those that are
> shared-on-purpose?

The instances should implement __copy__ and __deepcopy__
methods if they do something other than the ordinary.

http://www.python.org/doc/current/lib/module-copy.html

					Andrew
					dalke at dalkescientific.com





More information about the Python-list mailing list