Deepcopying numeric array
da at ski.org
Thu Aug 19 00:54:20 EDT 1999
On Thu, 19 Aug 1999, Greg Ewing wrote:
> Stuart Reynolds wrote:
> > Does anyone know why the Numeric arrays can't be deepcopied? Is it just
> > an omission?
That's an omission. With release 12 BETA, I added a __deepcopy__ method
in a single line:
def __deepcopy__(self, memo):
return array(self, copy=1)
This won't work for releases 1-11, though -- I don't have a fix for those
(btw, I don't understand what one is supposed to do w/ the memo
> Not only that, but I just found out a few minutes
> ago that they're un-comparable and un-hashable!
> Is there any good reason for these restrictions?
> Are they on hold awaiting Rich Comparisons or
Uncomparability is due to the fact that comparison of arrays right now is
impossible to do meaningfully. Meaningful comparison will have to wait
for rich comparisons, yes. In early version of NumPy, the comparison
returned the result of the comparison between the pointer values =). The
current behavior is better.
Unhashability is a direct consequence of the mutability, just as in the
case of dictionaries & lists.
More information about the Python-list