[Numpy-discussion] Proposal: Deprecate np.int, np.float, etc.?

Nathaniel Smith njs at pobox.com
Fri Jul 31 21:13:19 EDT 2015

On Jul 24, 2015 08:55, "Julian Taylor" <jtaylor.debian at googlemail.com>
> On 07/23/2015 04:29 AM, Nathaniel Smith wrote:
> > Hi all,
> >
> > So one of the things exposed in the numpy namespace are objects called
> >    np.int
> >    np.float
> >    np.bool
> > etc.
> >
> > These are commonly used -- in fact, just yesterday on another project
> > I saw a senior person reviewing a pull request instruct a more junior
> > person that they should use np.float instead of float or np.float64.
> > But AFAICT everyone who is actually using them is doing this based on
> > a very easy-to-fall-for misconception, i.e., that these objects have
> > something to do with numpy.
> I don't see the issue. They are just aliases so how is np.float worse
> than just float?

Because np.float systematically confuses people in a way that plain float
does not. Which is problematic given that we have a lot of users who aren't
expert programmers and are easily confused.

> Too me this does not seem worth the bother of deprecation.
> An argument could be made for deprecating creating dtypes from python
> builtin types as they are ambiguous (C float != python float) and
> platform dependent. E.g. dtype=int is just an endless source of bugs.
> But this is also so invasive that the deprecation would never be
> completed and just be a bother to everyone.

Yeah, I don't see any way to ever make dtype=int an error, though I can see
an argument for making it unconditionally int64 or intp. That's a separate
discussion... but every step we can make to simplify these names makes it
easier to untangle the overall knot, IMHO. (E.g. if people have different
expectations about what int and np.int should mean -- as they obviously do
-- then changing the meaning of both of them is harder than deprecating one
and then changing the other, so this deprecation puts us in a better
position even if it doesn't immediately help much.)

> So -1 from me.

Do you really mean this as a true veto? While some of the thread has gotten
a bit confused about how much of a change we're actually talking about,
AFAICT everyone else is very much in favor of this deprecation, including
testimony from multiple specific users who have gotten burned.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150731/3cf1db61/attachment.html>

More information about the NumPy-Discussion mailing list