[Numpy-discussion] zeros() default type in Numeric3

Robert Kern rkern at ucsd.edu
Mon Mar 28 07:44:18 CST 2005

Stephen Walton wrote:
> zeros() in Numeric3 defaults to typecode='d' while in numarray it 
> defaults to typecode=None, which in practice means 'i' by default.  Is 
> this deliberate? Is this desirable?  I'd vote for zeros(), ones() and 
> the like to default to 'i' or 'f' rather than 'd' in the interest of 
> space and speed.

For zeros() and ones(), I don't think space and speed are going to be 
affected by the default typecode. In my use of these functions, I almost 
always need a specific typecode. If I use the default, it's because I 
actually need the default typecode. Unfortunately, I almost always want 
Float and not Int, so all of my code is littered with

   zeros(shape, Float)

I'll bet Travis's code looks the same.

I would *love* to be able to spell these things like


Then we could leave zeros() and ones() defaults as they are for 
backwards compatibility, and deprecate the functions.

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

More information about the Numpy-discussion mailing list