[Numpy-discussion] Scalar casting rules use-case reprise

Nathaniel Smith njs@pobox....
Fri Jan 4 13:59:38 CST 2013


On Fri, Jan 4, 2013 at 11:09 AM, Matthew Brett <matthew.brett@gmail.com> wrote:
> In any case, can anyone remember the original use-cases well enough to
> record them for future decision making?

Heh. Everything new is old again. Here's a discussion from 2002 which
quotes the rationale:
  http://mail.scipy.org/pipermail/numpy-discussion/2002-September/014002.html

Note that in context:
  - numpy means the old Numeric library
  - AFAICT neither numeric nor numarray had special "scalar" types at
this point, and they didn't have 0d arrays either, so in fact indexing
an array would just return the closest python type (int or float). In
fact this is a thread about the problems this causes. (So the question
Dag raised downthread was prescient! Or, well, postscient, I guess.)

So it looks like the main reason was actually that back then, you
*couldn't* preserve non-native widths in operations involving scalars,
because there was no such thing as a non-native width scalar. As soon
as you called 'sum' or indexed an array, you reverted to native width.

-n


More information about the NumPy-Discussion mailing list