[Numpy-discussion] missing array type
tim.hochberg at cox.net
Tue Feb 28 13:57:02 CST 2006
>On 2/28/06, Colin J. Williams <cjw at sympatico.ca> wrote:
>>>>Would it not be better to have def zeroes(..., zeroStrides= False):
>>>>and a= zeros(..., zeroStrides= True)?
>>>This is equivalent to what I proposed: xzeros(shape) and xones(shape)
>>>functions as a shorthand to ndarray(shape, strides=(0,)*len(shape))
>>Wot, more names to remember? [sorry, I can't give you the graphic to go
>>aling with this. :-) ]
>Oh, please - you don't have to be so emphatic. Your solution above
>(adding zeroStrides parameter) would require a much more arbitrary
>name to remember. Even worse, someone will write zeros(shape, int,
>False, True) to mean zeros(shape, dtype=int, fortran=False,
>zeroStrides=True) and anyone reading that code will have to look up
>the manual to understand what each boolean means.
>Boolean parameters are generally considered bad design. For example,
>it would be much better to have array(..., memory_layout='Fortran')
>instead of current array(...,fortran=True). (Well, fortran=True is
>not that bad, but fortran=False is really puzzling - if it is not
>fortran - what is it?) Arguably even better solution would be
>array(..., strides = fortran_strides(shape)), but that's a different
I agree with this.
>The names xzeros and xones are a natural choice because the
>functionality they provide is very similar to what xrange provides
>compared to range: memory saving way to achieve the same result.
But not this.
I don't think using xrange as a template for naming anything is a good
idea. If xrange were being added to Python now, it would almost
certainly be called irange and live in itertools. I have a strong
suspicion that the *name* xrange will go the way of the dodo eventually,
although the functionality will survive in some other form.
Also, while I can see how there might well be some good uses for
zero-stride arrays, I'm having a hard time getting excited by by xzeros
and xones. The only applications I can come up with can already be done
in more efficient ways without using xones and xzeros.
[Let me apologize in advance if I missed a compelling example earlier in
this thread -- I just got back from vacation and I may have missed
something in my email reading frenzy]
More information about the Numpy-discussion