[PYTHON MATRIX-SIG] zero-dimension array silliness

Jim Phillips jim@ks.uiuc.edu
Thu, 24 Oct 96 15:35:23 -0500


You wrote:
> > > Not true at all.  It is important to be able to create rank-0 arrays in
> > > order to do:
> > >
> > > array_of_floats * array(3.14159, Float32)
>
> I also want to be able to write a * array(3.14, a.typecode()) sometimes, so
> I need to be able to create them with any type.

OK, now this seems to me a very silly discussion.  The reason that the  
problem of zero dimension arrays (scalars) even comes up is that it was  
decided, for efficiency reasons, that automatically converting arrays is bad.   
This argument DOES NOT APPLY to converting scalars!!!

Therefore, I propose the following "common sense" (Republican?) solution:

1) array types must match - type conversions must be explicit
2) Python scalars are automatically converted to the correct type

This way, no one should ever need to explicitly make a zero-dimension array,  
especially since Python scalars are always the largest typecode available (I  
think).  Arrays are arrays, Python scalars are scalars, problem solved!  Also,  
you don't need strange idioms (a * array(3.14, a.typecode())) for scalar  
multiplication (3.14 * a).

-Jim Phillips
 jim@ks.uiuc.edu

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================