8000 DOC: incorporate "upcoming changes" fragments into 2.0.0 release notes · numpy/numpy@34a8170 · GitHub
[go: up one dir, main page]

Skip to content

Commit 34a8170

Browse files
committed
DOC: incorporate "upcoming changes" fragments into 2.0.0 release notes
1 parent d17824f commit 34a8170

File tree

8 files changed

+101
-77
lines changed

8 files changed

+101
-77
lines changed

doc/release/upcoming_changes/25168.change.rst

Lines changed: 0 additions & 21 deletions
This file was deleted.

doc/release/upcoming_changes/25754.c_api.rst

Lines changed: 0 additions & 13 deletions
This file was deleted.

doc/release/upcoming_changes/25812.c_api.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

doc/release/upcoming_changes/25816.c_api.rst

Lines changed: 0 additions & 12 deletions
This file was deleted.

doc/release/upcoming_changes/25816.change.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

doc/release/upcoming_changes/25866.c_api.rst

Lines changed: 0 additions & 14 deletions
This file was deleted.

doc/source/reference/c-api/array.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3318,7 +3318,7 @@ Data Type Promotion and Inspection
33183318
for a ``singleton`` first and only calls the ``default_descr`` function if
33193319
necessary.
33203320
3321-
.. dtype-api_
3321+
.. _dtype-api:
33223322
33233323
Custom Data Types
33243324
-----------------

doc/source/release/2.0.0-notes.rst

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,31 @@ C API changes
342342

343343
(`gh-25789 <https://github.com/numpy/numpy/pull/25789>`__)
344344

345+
* The ``->f`` slot has been removed from ``PyArray_Descr``.
346+
If you use this slot, replace accessing it with
347+
``PyDataType_GetArrFuncs`` (see its documentation and the
348+
:ref:`numpy-2-migration-guide`). In some cases using other functions like
349+
``PyArray_GETITEM`` may be an alternatives.
350+
* ``PyArray_GETITEM`` and ``PyArray_SETITEM`` now require the import of the
351+
NumPy API table to be used and are no longer defined in ``ndarraytypes.h``.
352+
353+
(`gh-25812 <https://github.com/numpy/numpy/pull/25812>`__)
354+
355+
* Due to runtime dependencies, the definition for functionality accessing
356+
the dtype flags was moved from ``numpy/ndarraytypes.h`` and is only available
357+
after including ``numpy/ndarrayobject.h`` as it requires ``import_array()``.
358+
This includes ``PyDataType_FLAGCHK``, ``PyDataType_REFCHK`` and
359+
``NPY_BEGIN_THREADS_DESCR``.
360+
* The dtype flags on ``PyArray_Descr`` must now be accessed through the
361+
``PyDataType_FLAGS`` inline function to be compatible with both 1.x and 2.x.
362+
This function is defined in ``npy_2_compat.h`` to allow backporting.
363+
Most or all users should use ``PyDataType_FLAGCHK`` which is available on
364+
1.x and does not require backporting.
365+
Cython users should use Cython 3. Otherwise access will go through Python
366+
unless they use ``PyDataType_FLAGCHK`` instead.
367+
368+
(`gh-25816 <https://github.com/numpy/numpy/pull/25816>`__)
369+
345370
Datetime functionality exposed in the C API and Cython bindings
346371
---------------------------------------------------------------
347372

@@ -357,6 +382,7 @@ external libraries.
357382

358383
Const correctness for the generalized ufunc C API
359< 6D40 /td>384
-------------------------------------------------
385+
360386
The NumPy C API's functions for constructing generalized ufuncs
361387
(``PyUFunc_FromFuncAndData``, ``PyUFunc_FromFuncAndDataAndSignature``,
362388
``PyUFunc_FromFuncAndDataAndSignatureAndIdentity``) take ``types`` and ``data``
@@ -384,6 +410,7 @@ replaced with ``NPY_RAVEL_AXIS``. See also :ref:`migration_maxdims`.
384410

385411
``NPY_MAXARGS`` not constant and ``PyArrayMultiIterObject`` size change
386412
-----------------------------------------------------------------------
413+
387414
Since ``NPY_MAXARGS`` was increased, it is now a runtime constant and not
388415
compile-time constant anymore.
389416
We expect almost no users to notice this. But if used for stack allocations
@@ -398,14 +425,50 @@ to avoid issues with Cython.
398425

399426
Required changes for custom legacy user dtypes
400427
----------------------------------------------
428+
401429
In order to improve our DTypes it is unfortunately necessary
402-
to break with A 9E88 BI, which requires some changes for dtypes registered
403-
with `PyArray_RegisterDataType`.
404-
Please see the documentation of `PyArray_RegisterDataType` for how
430+
to break the ABI, which requires some changes for dtypes registered
431+
with ``PyArray_RegisterDataType``.
432+
Please see the documentation of ``PyArray_RegisterDataType`` for how
405433
to adapt your code and achieve compatibility with both 1.x and 2.x.
406434

407435
(`gh-25792 <https://github.com/numpy/numpy/pull/25792>`__)
408436

437+
New Public DType API
438+
--------------------
439+
440+
The C implementation of the NEP 42 DType API is now public. While the DType API
441+
has shipped in NumPy for a few versions, it was only usable in sessions with a
442+
special environment variable set. It is now possible to write custom DTypes
443+
outside of NumPy using the new DType API and the normal ``import_array()``
444+
mechanism for importing the numpy C API.
445+
446+
See :ref:`dtype-api` for more details about the API. As always with a new
447+
feature, please report any bugs you run into implementing or using a new
448+
DType. It is likely that downstream C code that works with dtypes will need to
449+
be updated to work correctly with new DTypes.
450+
451+
(`gh-25754 <https://github.com/numpy/numpy/pull/25754>`__)
452+
453+
New C-API import functions
454+
--------------------------
455+
456+
We have now added ``PyArray_ImportNumPyAPI`` and ``PyUFunc_ImportUFuncAPI``
457+
as static inline functions to import the NumPy C-API tables.
458+
The new functions have two advantages over ``import_array`` and
459+
``import_ufunc``:
460+
461+
- They check whether the import was already performed and are light-weight
462+
if not, allowing to add them judiciously (although this is not preferable
463+
in most cases).
464+
- The old mechanisms were macros rather than functions which included a
465+
``return`` statement.
466+
467+
The ``PyArray_ImportNumPyAPI()`` function is included in ``npy_2_compat.h``
468+
for simpler backporting.
469+
470+
(`gh-25866 <https://github.com/numpy/numpy/pull/25866>`__)
471+
409472

410473
NumPy 2.0 C API removals
411474
========================
@@ -983,6 +1046,14 @@ Changes
9831046

9841047
(`gh-25080 <https://github.com/numpy/numpy/pull/25080>`__)
9851048

1049+
* The ``dtype.flags`` value was previously usually stored as a signed integer.
1050+
This means that the aligned dtype struct flag lead to negative flags being
1051+
set (-128 rather than 128). This flag is now stored unsigned (positive). Code
1052+
which checks flags manually may need to adapt. This may include code
1053+
compiled with Cython 0.29.x.
1054+
1055+
(`gh-25816 <https://github.com/numpy/numpy/pull/25816>`__)
1056+
9861057
Representation of NumPy scalars changed
9871058
---------------------------------------
9881059
As per :ref:`NEP 51 <NEP51>`, the scalar representation has been
@@ -1127,6 +1198,32 @@ Any out of bound axis value will now error, make sure to use
11271198

11281199
(`gh-25149 <https://github.com/numpy/numpy/pull/25149>`__)
11291200

1201+
New ``copy`` keyword meaning for `numpy.array` and `numpy.asarray`
1202+
------------------------------------------------------------------
1203+
Now `numpy.array` and `numpy.asarray` support three values for ``copy`` parameter:
1204+
1205+
* ``None`` - A copy will only be made if it is necessary.
1206+
* ``True`` - Always make a copy.
1207+
* ``False`` - Never make a copy. If a copy is required a ``ValueError`` is raised.
1208+
1209+
The meaning of ``False`` changed as it now raises an exception if a copy is needed.
1210+
1211+
(`gh-25168 <https://github.com/numpy/numpy/pull/25168>`__)
1212+
1213+
The ``__array__`` special method now takes a ``copy`` keyword argument.
1214+
-----------------------------------------------------------------------
1215+
1216+
NumPy will pass ``copy`` to the ``__array__`` special method in situations where
1217+
it would be set to a non-default value (e.g. in a call to
1218+
``np.asarray(some_object, copy=False)``). Currently, if an
1219+
unexpected keyword argument error is raised after this, NumPy will print a
1220+
warning and re-try without the ``copy`` keyword argument. Implementations of
1221+
objects implementing the ``__array__`` protocol should accept a ``copy`` keyword
1222+
argument with the same meaning as when passed to `numpy.array` or
1223+
`numpy.asarray`.
1224+
1225+
(`gh-25168 <https://github.com/numpy/numpy/pull/25168>`__)
1226+
11301227
Cleanup of initialization of ``numpy.dtype`` with strings with commas
11311228
---------------------------------------------------------------------
11321229
The interpretation of strings with commas is changed slightly, in that a

0 commit comments

Comments
 (0)
0