[Numpy-discussion] numpy endian question

Christopher Hanley chanley at stsci.edu
Fri Apr 27 08:49:16 EDT 2007


Stefan van der Walt wrote:
> On Thu, Apr 26, 2007 at 05:22:42PM -0400, Christopher Hanley wrote:
>   
>> This should work as a consistent test for bigendian:
>>
>> -> isBigEndian = (obj.dtype.str[0] == '>')
>>     
>
> Is this test always safe, even on big endian machines?  Couldn't the
> dtype.str[0] sometimes be '='?
>
> Regards
> Stéfan
> _______________________________________________
>   
The test does would on big endian machines.  What wouldn't work would be 
something like this:

-> isBigEndian = (obj.dtype.byteorder == '>')


On a big-endian machine you would get '=' in this case.

Cheers,
Chris




More information about the NumPy-Discussion mailing list