[Numpy-discussion] Integers to integer powers, let's make a decision
Alan Isaac
alan.isaac at gmail.com
Fri Jun 10 13:50:47 EDT 2016
On 6/10/2016 1:34 PM, Nathaniel Smith wrote:
> You keep pounding on this example. It's a fine example, but, c'mon. **2 is probably at least 100x more common in real source code. Maybe 1000x more common. Why should we break the
> common case for your edge case?
It is hardly an "edge case".
Again, **almost all** integer combinations overflow: that's the point.
If you were promoting to a Python long integer, that would change things.
But hobbling a whole operator so that people don't have to say `a*a` seems
absurdly wasteful. Additionally, returning floats provides a better
match to Python's behavior (i.e., it allows sensible handling of
negative powers). Users who really want in output and understand
overflow should be supported with a function.
Anyway, I've said my piece and will shut up now.
Cheers,
Alan
More information about the NumPy-Discussion
mailing list