Nathaniel Smith
2016-01-22 00:21:48 UTC
So it turns out that ndarray.data supports assignment at the Python
level, and what it does is just assign to the ->data field of the
ndarray object:
https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/getset.c#L325
This kind of assignment been deprecated at the C level since 1.7, and
is totally unsafe -- if there are any views pointing to the array when
this happens, then they'll be left pointing off into unallocated
memory.
E.g.:
a = np.arange(10)
b = np.linspace(0, 1, 10)
c = a.view()
a.data = b.data
# Now c points into free'd memory
Can we deprecate or just remove this?
(Also filed issue: https://github.com/numpy/numpy/issues/7093)
-n
level, and what it does is just assign to the ->data field of the
ndarray object:
https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/getset.c#L325
This kind of assignment been deprecated at the C level since 1.7, and
is totally unsafe -- if there are any views pointing to the array when
this happens, then they'll be left pointing off into unallocated
memory.
E.g.:
a = np.arange(10)
b = np.linspace(0, 1, 10)
c = a.view()
a.data = b.data
# Now c points into free'd memory
Can we deprecate or just remove this?
(Also filed issue: https://github.com/numpy/numpy/issues/7093)
-n
--
Nathaniel J. Smith -- https://vorpus.org
Nathaniel J. Smith -- https://vorpus.org