[MATRIX-SIG] Suggestion: alias __deepcopy__ as __copy__ for arrays ??

Konrad Hinsen hinsen@ibs.ibs.fr
Tue, 24 Feb 1998 10:50:08 +0100


> The standard module copy will not do a deepcopy of class instances
> if they contain Numeric arrays.  This seems to be because the
> array type does not define a __deepcopy__ function.
> (Numeric does define a __copy__ function.)

Right.

> However, it seems that for most cases of Numeric arrays
> (float, int, byte, etc.) a __deepcopy__ is equivalent to a __copy__.
> [How could a deepcopy be different than a copy for an array??]
> IF, (repeat IF), this is true, then it seems that a
> __deepcopy__ method can be defined as an alias to the __copy__ method.
> That way, a deepcopy of objects containing arrays should work.

Right again. However, there is one type of array for which deepcopy
is not equivalent to a simple copy: general object arrays. So there
must be a separate routine for deepcopy, and someone must write it...
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-4.76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________