[Numpy-discussion] Oddity with numpy.int64 integer division
Tue Apr 24 16:33:52 CDT 2007
On 4/24/07, Robert Kern <email@example.com> wrote:
> Christian Marquardt wrote:
> > Restore the invariant, and follow python.
This seems to imply that once upon a time numpy/numeric/numarray followed
python here, but as far as I can recall that was never the case. Instead
they followed C completely, ostensibly for performance reasons. That
preserved the invariant in question, but not compatibility with Python.
> > This
> > >>> -5 // 6
> > -1
> > and
> > >>> array([-5]) // 6
> > 0
> > simply doesn't make sense - in any language, you would expect that
> > all basic operators provide you with the same same answer when
> > applied to the same number, no?
> Not if they are different types, you don't, e.g. -5.0 / 6 .
That's perhaps not the best example since this difference is slated for
>>> from __future__ import division
Personally I'd opt for completely following Python here, with the C-like
integer division and mod operators available as appropriately named ufuncs
somewhere. It's a backwards incompatible change though, so it'd have to wait
till at least a minor realease.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion