[Numpy-discussion] Re: byteswap questions

Russell E. Owen rowen at cesmail.net
Wed Nov 2 14:53:09 EST 2005

In article <1130838789.2968.23.camel at localhost.localdomain>,
 Francesc Altet <faltet at carabos.com> wrote:

> El dl 31 de 10 del 2005 a les 16:53 -0800, en/na Russell E. Owen va
> escriure:
> > I've got a module that can send array data to ds9. It screws up on 
> > byteswapped data and I'm trying to fix it.
> I don't exactly know what a ds9 is, but I'm supposing here that it is
> kind of an exotic computer.

It's an image display program.

> > I need to know if the order is bigendian or littleendian, and I can't 
> > find a documented way to get that, just an undocumented attribute 
> >  byteorder.
> Yes, it's undocumented, but as far as I can tell, this works flawlessly
> in numarray.

I'm sure it works now. I was hoping to know if it would continue working 
in future versions. It'd be nice to have a documented way to get at the 

> In general, copy() will return you a well-behaved (native-byte ordered,
> non-strided and non-offsetted) array.

The manual promises that a copy will be contiguous but I didn't see a 
promise of native byte order. I have submitted a documentation PR on 

Thanks for the explanation of what byteswapped was doing. That was very 

To use documented interfaces (i.e. not arra._byteorder) and to avoid 
byteswapping the input array, I think I'm going to be stuck doing 
something like:

import sys
if sys.byteorder == 'big':
   isBigendian = not arr.isbyteswapped()
   isBigendian = arr.isbyteswapped()

I also submitted a request for a documented direct way to get the info 
on sourceforge.


-- Russell

More information about the NumPy-Discussion mailing list