[Numpy-discussion] immutable numpy arrays

Robert Kern robert.kern@gmail....
Thu Dec 18 15:00:35 CST 2008


On Thu, Dec 18, 2008 at 10:01, Geoffrey Irving <irving@naml.us> wrote:
> On Wed, Dec 17, 2008 at 4:28 PM, Robert Kern <robert.kern@gmail.com> wrote:

>> It just seems to me to be another complication that does not provide
>> any guarantees. You say "Currently numpy arrays are either writable or
>> unwritable, but unwritable arrays can still be changed through other
>> copies." Adding an immutable flag would just change that to "Currently
>> numpy arrays are either mutable or immutable, but immutable arrays can
>> still be changed through other copies." Basically, the writable flag
>> is intended to indicate your use case. It can be circumvented, but the
>> same methods of circumvention can be applied to any set of flags.
>
> The point of an immutable array would be that _can't_ be changed
> through other copies except through broken C code (or the ctypes /
> __array_interface__ equivalents), so it's not correct to say that it's
> the same as unwriteable.  It's the same distinction as C++ const vs.
> Java final.  Immutability is already a common notion in python, e.g.,
> list vs. tuple and set vs. frozenset, and it's unfortunate that numpy
> doesn't have an equivalent.
>
> However, if you agree that even _with_ the guarantee it's not a useful
> concept, I'm happy to drop it.

What I'm trying to suggest is that most code already treats the
writeable flag like I think you want the immutable flag to be treated.
I'm not sure what you think is missing.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list