[Numpy-discussion] Integers to integer powers, let's make a decision

Juan Nunez-Iglesias jni.soma at gmail.com
Fri Jun 10 12:49:10 EDT 2016


+1 to Alan's point. Having different type behaviour depending on the values
of x and y for np.arange(x) ** y would be awful, and it would also be awful
to have to worry about overflow here...

...

Having said that, it would be equally annoying to not have a way to define
integer powers...


From: Alan Isaac <alan.isaac at gmail.com> <alan.isaac at gmail.com>
Reply: Discussion of Numerical Python <numpy-discussion at scipy.org>
<numpy-discussion at scipy.org>
Date: 10 June 2016 at 5:10:57 AM
To: Discussion of Numerical Python <numpy-discussion at scipy.org>
<numpy-discussion at scipy.org>
Subject:  Re: [Numpy-discussion] Integers to integer powers, let's make a
decision

On 6/10/2016 2:42 AM, Nathaniel Smith wrote:
>
> I dunno, with my user hat on I'd be incredibly surprised / confused /
> annoyed if an innocent-looking expression like
>
> np.arange(10) ** 2
>
> started returning floats... having exact ints is a really nice feature
> of Python/numpy as compared to R/Javascript, and while it's true that
> int64 can overflow, there are also large powers that can be more
> precisely represented as int64 than float.
>
>
>
> Is np.arange(10)**10 also "innocent looking" to a Python user?
>
> Also, I am confused by what "large powers" means in this context.
> Is 2**40 a "large power"?
>
> Finally, is np.arange(1,3)**-2 "innocent looking" to a Python user?
>
> Cheers,
> Alan
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160610/8af9b611/attachment.html>


More information about the NumPy-Discussion mailing list