diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-12-04 10:51:24 -0600 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-12-04 11:47:02 -0600 |
commit | d169276c467903be95f1ba94de1cee9bb32b280a (patch) | |
tree | 7af04b5e5f0a482beddd591e9187e73ec26003f2 | |
parent | e538e11d2b0acd93f5ce74fb3c6a0e25a4aa3ef8 (diff) | |
download | numpy-d169276c467903be95f1ba94de1cee9bb32b280a.tar.gz |
DOC: Update release notes to mention `type(dtype) is not np.dtype`
This also requires mentioning the C-API macro
`#define PyArray_DescrCheck(op) PyObject_TypeCheck(op, &PyArrayDescr_Type)`
which was updated to the above in 1.16.6 meaning that using the
macro and compiling against an older NumPy version will cause
issues. The macro has to be avoided in that case.
-rw-r--r-- | doc/source/release/1.20.0-notes.rst | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/source/release/1.20.0-notes.rst b/doc/source/release/1.20.0-notes.rst index 73b470f3f..9f46a3e80 100644 --- a/doc/source/release/1.20.0-notes.rst +++ b/doc/source/release/1.20.0-notes.rst @@ -253,6 +253,18 @@ library. Compatibility notes =================== +``isinstance(dtype, np.dtype)`` and not ``type(dtype) is not np.dtype`` +----------------------------------------------------------------------- +NumPy dtypes are not direct instances of ``np.dtype`` anymore. Code that +may have used ``type(dtype) is np.dtype`` will always return ``False`` and +must be updated to use the correct version ``isinstance(dtype, np.dtype)``. + +This change also affects the C-side macro ``PyArray_DescrCheck`` if compiled +against a NumPy older than 1.16.6. If code uses this macro and wishes to +compile against an older version of NumPy, it must replace the macro +(see also `C API changes`_ section). + + Same kind casting in concatenate with ``axis=None`` --------------------------------------------------- When `~numpy.concatenate` is called with ``axis=None``, @@ -524,6 +536,23 @@ cannot represent ``b"1"`` faithfully. C API changes ============= +The ``PyArray_DescrCheck`` macro is modified +-------------------------------------------- +The ``PyArray_DescrCheck`` macro has been updated since NumPy 1.16.6 to be:: + + #define PyArray_DescrCheck(op) PyObject_TypeCheck(op, &PyArrayDescr_Type) + +Starting with NumPy 1.20 code that is compiled against an earlier version +will be API incompatible with NumPy 1.20. +The fix is to either compile against 1.16.6 (if the NumPy 1.16 release is +the oldest release you wish to support), or manually inline the macro by +replacing it with the new definition:: + + PyObject_TypeCheck(op, &PyArrayDescr_Type) + +which is compatible with all NumPy versions. + + Size of ``np.ndarray`` and ``np.void_`` changed ----------------------------------------------- The size of the ``PyArrayObject`` and ``PyVoidScalarObject`` |