On Wed, 2026-02-11 at 11:35 +0100, Pieter Eendebak via NumPy-Discussion
wrote:
> Hi everyone,
> 
> In the Python free-threading build, mutating properties of a NumPy
> array
> can corrupt the interpreter state. To address this, we have already
> deprecated setting the shape or strides of an array. As a next step,
> we
> would like to also deprecate setting ndarray.dtype and calling
> ndarray.resize. The tracking issue for this effort is:
> https://github.com/numpy/numpy/issues/28800.
> 
> Safe alternatives exist for both operations. For example, instead of
> setting the dtype directly, users can create a new view with
> array.view(new_dtype).
> 
> Since deprecations can affect downstream packages, we would like to
> gather
> feedback before proceeding:
> 
> * Are there any objections to deprecating these operations in NumPy
> 2.5? If
> so, what are the concerns?
> * Which packages currently rely on setting ndarray.dtype or calling
> ndarray.resize?
> * Should we provide a public API for these operations? (The proposed
> PR
> currently includes a private API.)


Thanks!  I am happy with deprecation. I think the deprecation that
caused most churn here is the `.shape` setting deprecation anyway. This
one I am less concerned about.

About "public API"

For me making it public would mean two things: promising to not just
remove it in the future and pointing to it maybe just via the error:
```
>>> arr.dtype = np.dtype("i8")
TypeError: Cannot change dtype on array please use `arr.view()`. If you
need to do change the dtype unsafely see `arr._set_dtype` and inform
yourself about the why and how it is unsafe.
```

It seems harmless to keeping such "hidden but considered public"
methods around. So if there is any hesitance around this, I think we
should just do that.
But I don't want to remove the `_` since IMO there is no reason for
this to be discoverable.

Cheers,

Sebastian


> 
> Kind regards,
> Pieter Eendebak
> _______________________________________________
> NumPy-Discussion mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3//lists/numpy-discussion.python.org
> Member address: [email protected]
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]

Reply via email to