[SciPy-dev] Notes from meeting with Guido regarding inclusion of array package in Python core

Perry Greenfield perry at stsci.edu
Thu Mar 10 14:29:31 CST 2005

On Mar 10, 2005, at 2:41 PM, Charles R Harris wrote:
> I agree that this is a difficult problem and it is hard to make a
> decision. I think the simplest solution is to return rank-0 arrays. 
> Once
> people get used to this it should seem natural and obviate all that
> checking that currently goes on. Overhead is a concern, but I suspect
> that the heavy computation lifting will be done by the array routines,
> not python code. However, it is important to make sure it is easy to
> write extensions so things can be prototyped in python, then made
> efficient with an extension. One further problem with this approach is
> that python types need to be cast to suitable types for the array. When
> working with, say, a float array and multiplying by a python 1.0, it
> would be undesirable to return the result as a double. Using rank-0
> arrays preserves the type info, but for python scalars perhaps we need
> some simple typecast functions so that one can write 
> Int16(pythonScalar)
> and get the appropriate scalar to use in a numeric routine. Perhaps a
> special Numeric3 scalar type would be appropriate and address the
> efficiency problems.
Actually, the coercion issue is already handled by the fact that either 
numarray or Numeric3 arrays don't allow scalars to force coercion of 
arrays unless the scalar is of a "higher" kind than arrays (e.g., float 
scalar with int array). So multiplying an Int16 array with the constant 
3 won't change the result to Int32.


More information about the Scipy-dev mailing list