[Numpy-discussion] Matching 0-d arrays and NumPy scalars

Travis E. Oliphant oliphant@enthought....
Thu Feb 21 10:33:26 CST 2008


Damian Eads wrote:
> While we are on the subject of indexing... I use xranges all over the 
> place because I tend to loop over big data sets. Thus I try avoid to 
> avoid allocating large chunks of memory unnecessarily with range. While 
> I try to be careful not to let xranges propagate to the ndarray's [] 
> operator, there have been a few times when I've made a mistake. Is there 
> any reason why adding support for xrange indexing would be a bad thing 
> to do? All one needs to do is convert the xrange to a slice object in 
> __getitem__. I've written some simple code to do this conversion in 
> Python (note that in C, one can access the start, end, and step of an 
> xrange object very easily.)
>   
I think something like this could be supported.   Basically, 
interpreting an xrange object as a slice object would be my presumed 
behavior.

-Travis O.



More information about the Numpy-discussion mailing list