Skip to content

EXP: construct proper np.memmap objects for memory-mapped numpy arrays in astropy.io.fits#19502

Draft
astrofrog wants to merge 3 commits intoastropy:mainfrom
astrofrog:fits-memmap
Draft

EXP: construct proper np.memmap objects for memory-mapped numpy arrays in astropy.io.fits#19502
astrofrog wants to merge 3 commits intoastropy:mainfrom
astrofrog:fits-memmap

Conversation

@astrofrog
Copy link
Copy Markdown
Member

@astrofrog astrofrog commented Mar 27, 2026

NOTE: this is not ready for looking at yet, I need to experiment with it more!

This is an experimental PR inspired by discussion and comments from @saimn in #18665 - the question here is could we actually use proper np.memmap objects instead of using np.ndarray backed by a mmap.

The main thing this would break is if someone had something like if type(hdu.data) is np.ndarray, but things like isinstance(hdu.data, np.ndarray) would continue to work, and all array usage should just work as far as I can see.

The benefit of doing this is that it makes it easier for users and downstream libraries to (e.g. reproject) to have access to the memory map parameters, which can then help decide on strategies for e.g. serializing in a multiprocessing environment, but there might also be other benefits. At the very least it makes it obvious to users if an array is memory mapped since otherwise there isn't actually a way to know from the array if it is memory mapped or in memory.

This is up for discussion/experimenting with, not for merging at this point - we might decide we don't want to do it.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions github-actions bot added io.fits utils and removed Extra CI Run cron CI as part of PR labels Mar 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@astrofrog astrofrog added the Build all wheels Run all the wheel builds rather than just a selection label Mar 27, 2026
@astrofrog astrofrog added the Extra CI Run cron CI as part of PR label Mar 27, 2026
@pllim pllim added this to the v8.0.0 milestone Mar 27, 2026
@astrofrog
Copy link
Copy Markdown
Member Author

@pllim - I'm not sure I would milestone this quite yet, I doubt we will merge it 😅

@pllim
Copy link
Copy Markdown
Member

pllim commented Mar 27, 2026

Re: milestone -- Just to get the check to pass. We will re-milestone anyway at branching time, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build all wheels Run all the wheel builds rather than just a selection Experimental Extra CI Run cron CI as part of PR io.fits needs-discussion utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants