[Numpy-discussion] Deprecating python type aliases (np.int, np.long, np.str, ...)

Sebastian Berg sebastian at sipsolutions.net
Thu Jun 11 10:59:18 EDT 2020

Hi all,

In the pull request: https://github.com/numpy/numpy/pull/14882
Eric proposes to deprecate the type aliases which NumPy imports
into its main namespace (e.g. np.int, np.bool, see table below [1]).

Right now there seems to be a consensus to move this forward and I plan
on doing that, so this is a heads-up in case anyone has a differing

The deprecation should not be very noisy as such, but I expect it will
require many projects to update their code in the long run (although
the changes are very simple).

One advantage is that some aliases are confusing, e.g. `np.float` is
Python float, and thus actually a `float64` and not a C `float`, which
is a `float32`.

For an example of how this affects a code-base, this is SciPy:
(A chunk of the full PR unrelated style fixes).



[1] Full table of deprecated aliases:

==================  =====================  ============================
Deprecated          Equivalent to          Possibly intended numpy type
==================  =====================  ============================
``numpy.bool``      ``bool``               `numpy.bool_`
``numpy.int``       ``int``                `numpy.int_` (default int dtype), `numpy.cint` (C ``int``)
``numpy.float``     ``float``              `numpy.float_`, `numpy.double` (equivalent)
``numpy.complex``   ``complex``            `numpy.complex_`, `numpy.cdouble` (equivalent)
``numpy.object``    ``object``             `numpy.object_`
``numpy.str``       ``str``                `numpy.str_`
``numpy.long``      ``numpy.compat.long``  `numpy.int_` (C ``long``), `numpy.longlong` (largest integer type)
``numpy.unicode``   ``numpy.compat.str``   `numpy.unicode_`
==================  =====================  ==========================

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20200611/c3981165/attachment-0001.sig>

More information about the NumPy-Discussion mailing list