On Wed, Mar 25, 2015 at 1:45 PM, Benjamin Root <ben.r...@ou.edu> wrote:
> I fail to see the wtf. > > flags = a.flags > > So, "flags" at this point is just an alias to "a.flags", just like any > other variable in python > > "flags.writeable = False" would then be equivalent to "a.flags.writeable = > False". There is nothing numpy-specific here. a.flags is mutable object. > This is how Python works. > > Ben Root > Ah, yes indeed. If you think of it that way it does make all the sense in the world. But of course that is not what is actually going on, as flags is a single C int of the PyArrayObject struct, and a.flags is just a proxy built from it, and great coding contortions have to be made to have changes to the proxy rewritten into the owner array. I guess then the surprising behavior is this other one, which was the one I (wrongly) expected intuitively: >>> a = np.arange(10) >>> flags = a.flags >>> a.flags.writeable = False >>> flags C_CONTIGUOUS : True F_CONTIGUOUS : True OWNDATA : True WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False This could be fixed to work properly, although it is probably not worth worrying much. Properties of properties are weird... Jaime
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion