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

Charles R Harris charlesr.harris at gmail.com
Sat Jun 4 20:07:22 EDT 2016


On Sat, Jun 4, 2016 at 5:27 PM, <josef.pktd at gmail.com> wrote:

>
>
> On Sat, Jun 4, 2016 at 6:10 PM, Nathaniel Smith <njs at pobox.com> wrote:
>
>> On Sat, Jun 4, 2016 at 2:07 PM, V. Armando Sole <sole at esrf.fr> wrote:
>> > Also in favor of 2. Always return a float for '**'
>>
>> Even if we did want to switch to this, it's such a major
>> backwards-incompatible change that I'm not sure how we could actually
>> make the transition without first making it an error for a while.
>>
>
> AFAIU, only the dtype for int**int would change. So, what would be the
> problem with FutureWarnings as with other dtype changes that were done in
> recent releases.
>
>
The main problem I see with that is that numpy integers would behave
differently than Python integers, and the difference would be silent. With
option 1 it is possible to write code that behaves the same up to overflow
and the error message would supply a warning when the exponent should be
float. One could argue that numpy scalar integer types could be made to
behave like python integers, but then their behavior would differ from
numpy arrays and numpy scalar arrays.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160604/68546e9f/attachment.html>


More information about the NumPy-Discussion mailing list