-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate/remove array_data_set #7093
Comments
Mailing list post: https://mail.scipy.org/pipermail/numpy-discussion/2016-January/074708.html |
Sure, see also gh-5958, but Jaime never came around to doing the deprecation instead of just removing it. Of course if we want to see if we can just remove it.... |
Doh, thanks :-) Given that we have bugs back to 2009 complaining about this and no-one speaking up in favor, it sounds like deprecating it at least is a no-brainer. |
I sometimes don't read long threads with sufficient attention... Was it agreed that this should be deprecated? I thought there was some concerns that things may break somewhere, |
From skimming the old bug reports about this, I think the only positions On Thu, Jan 21, 2016 at 4:45 PM, Jaime notifications@github.com wrote:
Nathaniel J. Smith -- https://vorpus.org http://vorpus.org |
By the way, the docs cite #7083 as the reason for the deprecation, not this issue (a small one-digit typo it seems). I don't fully agree with this deprecation, though I understand the reasoning for it. There is at least one valid use case I have had for updating This first came to my attention in astropy/astropy#5797. The reasoning behind it is that in Astropy, there are objects representing a FITS file--an astronomy data format. The data in FITS files can be accessed as mmap-backed Numpy arrays. There is functionality for performing "in-place" updates of FITS files, including updates which resize the original file. Resizing--especially if data in the middle of the file is being resized--often means an in-place rewrite of the file. This means writing to a temp file, and then renaming the temp file over the original file. As Astropy is often used in interactive data analysis sessions, the following scenario is not unheard of:
On most OS's this is not a problem. E.g. Linux will keep the original file data around, and just move dirents around instead. On Windows, however, this is a problem. It is not possible to delete or rename a file while there are still open handles to that file, including handles used for memory mapping. Therefore, in order to perform such an in-place update, it is necessary on Windows to close the That's easy enough to do, but the user, who is generally an astronomer unwary of things like mmaps and file handles, may still try to access The workaround, then, is after rewriting the file to open new mmaps to the data that was already loaded, but backed by the new file, and then to update each As an alternative, I'd be happy enough if the scenario I described above still broke the user's original reference to the array ( |
This sounds like a discussion that should happen on the mailing list. |
@charris You're right, of course , I just wanted to place my comments in context; but I can also bring it up there. |
It would be good to bring it up there. |
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.:
Can we deprecate or just remove this?
The text was updated successfully, but these errors were encountered: