Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@eendebakpt
Copy link
Contributor

Addresses part of #28800

We deprecate ndarray.resize in the type hints. In a followup PR (probably for a next numpy release) we will issue a deprecating working when ndarray.resize is called.

@eendebakpt eendebakpt changed the title Draft: DEP: Deprecate ndarray.resize DEP: Deprecate ndarray.resize Nov 9, 2025
@eendebakpt eendebakpt requested a review from jorenham November 9, 2025 11:57
Copy link
Member

@jorenham jorenham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got nothing to complain 👌

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense!

@charris charris modified the milestone: 2.4.0 release Nov 9, 2025
Co-authored-by: Joren Hammudoglu <[email protected]>
@seberg
Copy link
Member

seberg commented Nov 10, 2025

Will we make type-hint only deprecations a pattern now? FWIW, it seems nice it seems like a nice way to potentially get some feedback about impact (and I guess some libraries may clean it up before there even is a warning, which is a small bonus too)!

I do have a slight worry with this one that while it won't be much code that is affected, it may not always be obvious how to replace resize. Typically, one can concate, sometimes use fromiter occasionally it may just be a reshape anyway.

The least obvious extreme case might be that the resize actually does make sense and one might have to use data = bytearray(...); tmp_view = np.frombuffer(data) (to actually keep reallocating).

@mhvk
Copy link
Contributor

mhvk commented Nov 10, 2025

Internally, we seem to use it mostly in places where we're reading from a file, and the array should be extended. I think this would often involve a copy (not sure how likely it is memory right after an array allocated earlier is still available). In any python code at least, this is fairly trivially done with concatenate.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants