GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DOC: document caveats of ndarray.resize on 3.14 and newer by charris · Pull Request #31058 · numpy/numpy

Conversation

@charris

@charris charris commented Mar 24, 2026

Copy link
Copy Markdown
Member

Backport of #31021.

Closes #30991.

This doesn't "fix" the regression, because I don't think there's a way to do that without introducing new bugs or depending on interpreter internals and/or trying to argue for yet another PyUnstable C API function we can use.

I'm also a little concerned that the old check is actually incorrect for arrays created by C extensions: the check on 3.13 and older allows resizing an array created directly via e.g. PyArray_FromAny with exactly one reference.

IMO it's better to keep the logic of the check the same and simply improve the documentation and error messages.

Now when the reference count is exactly 2, the error message on 3.14 and newer explains that this might be a false positive.

I added tests which trigger the behaviors we expect to happen on different Python versions. I also deleted some out-of-date docs about an unused order argument and added some notes that resizing in-place can lead to memory fragmentation and worse overall memory usage.

Also looking for any ideas for ways to make the error messages and docstrings less wordy.
-->

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ngoldbaum and others added 9 commits March 23, 2026 18:20
@ngoldbaum @charris
DOC: document caveats of ndarray.resize on 3.14 and newer
22440ed
@ngoldbaum @charris
skip test using subprocesses on wasm
099cfa0
@ngoldbaum @mattip @charris
Update doc/source/reference/c-api/array.rst
5accdc0
Co-authored-by: Matti Picus <[email protected]>
@ngoldbaum @mattip @charris
Update numpy/_core/src/multiarray/shape.c
ba117bf
Co-authored-by: Matti Picus <[email protected]>
@ngoldbaum @charris
TST: fix issues with tests
70daac6
@ngoldbaum @charris
Respond to Matti's comments
ae46e31
@ngoldbaum @charris
DOC: Apply Marten's comments and rephrase slightly
65022e5
@ngoldbaum @mattip @charris
Update numpy/_core/src/multiarray/shape.c
a3ca5ed
Co-authored-by: Matti Picus <[email protected]>
@charris
MAINT: Remove unused import of tracemalloc.
4c5fdd6
@charris charris added this to the 2.4.4 release milestone Mar 24, 2026
@charris charris added 04 - Documentation 08 - Backport Used to tag backport PRs labels Mar 24, 2026
@charris
MAINT: Skip test on PyPy.
7f13b5a
Also fix typo.
@charris
charris merged commit 8052c4b into numpy:maintenance/2.4.x Mar 24, 2026
71 checks passed

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

04 - Documentation 08 - Backport Used to tag backport PRs

Projects

None yet

Milestone

2.4.4 release

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@charris @ngoldbaum
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.