On Tue, Oct 16, 2012 at 4:36 PM, Byron Blay <[email protected]> wrote:
> Copying / deepcopying an array does not copy the writeable flag:
>
>>>> import numpy
>>>> from copy import deepcopy
>>>> a = numpy.array([1,2,3,4,5])
>>>> a.flags.writeable = False
>>>> b = deepcopy(a)
>>>> b.flags.writeable
> True
>
> Is this a bug?
> Should I raise an issue on github?

I think this is intended? numpy doesn't really think of writeable and
non-writeable arrays as being different sorts of objects;
flags.writeable just records a fact about the underlying memory that
the array refers to. If you make a new copy, then (by definition!) you
get a nice new chunk of freshly allocated memory, and the memory is
writeable.

That said, this might not be the most useful approach. Can you
elaborate on your situation where this is causing a problem?

-n
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to