[Numpy-discussion] Re: byteswap questions
Russell E. Owen
rowen at cesmail.net
Thu Nov 3 12:05:57 CST 2005
In article <Pine.OSX.4.58.0511030849170.5996 at catnip.local>,
Rick White <rlw at stsci.edu> wrote:
> On Wed, 2 Nov 2005, Russell E. Owen wrote:
>
> > 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()
> > else:
> > isBigendian = arr.isbyteswapped()
>
> A simpler version:
>
> isBigendian = arr.isbyteswapped() != numarray.isBigEndian
Cute. isBigEndian doesn't seem to be present in Numeric 23.8. I wonder
if it'll be in scipy.core.
Based on stunningly fast responses by Jay T Miller to most of the PRs I
submitted to sourceforge:
- The byteswap and byteswapped methods do just affect the data and not
the byteorder flag. The doc string for byteswapped said otherwise and
that is fixed in the repository. I don't know if the manual has been
clarified.
- To toggle the byteorder flag, use the togglebyteorder method (duh, I
wish I'd seen that one).
- An official way to figure out if an array is byteswapped is to use the
__array_typestr__ method and look at the first character of the returned
string. "<" means little-endian, ">" means big-endian. This is
apparently also part of the array interface for scipy.core. I sure hope
there'll be a more obvious method to call than __array_typestr__ at some
point.
-- Russell
More information about the Numpy-discussion
mailing list