[Numpy-discussion] numpy endian question

Russell E. Owen rowen at cesmail.net
Thu Apr 26 17:17:44 EDT 2007


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

> El dj 26 de 04 del 2007 a les 11:38 -0700, en/na Russell E. Owen va
> escriure:
> > In converting some code from numarray to numpy I had this:
> > isBigendian = (arr.isbyteswapped() != numarray.isBigEndian)
> > 
> > The only numpy version I've come up with is:
> > isBigEndian = (arr.dtype.descr[0][1][0] == '>')
> 
> isBigEndian = (arr.dtype.str[0] == '>')
> 
> is a little bit shorter. A more elegant approach could be:
> 
> isBigEndian = arr.dtype.isnative ^ numpy.little_endian

Thank you. That's just what I wanted (I had looked for the numpy version 
of numarray.isBigEndian but somehow missed it). Your other suggestion is 
also much nicer than my version, but I'll use the latter.

-- Russell



More information about the NumPy-Discussion mailing list