[Numpy-discussion] numpy.ascontiguousarray on byteswapped data !?

Sebastian Haase haase at msg.ucsf.edu
Fri Aug 11 00:32:28 EDT 2006


Travis Oliphant wrote:
> Sebastian Haase wrote:
>> Hi,
>> Does numpy.ascontiguousarray(arr) "fix" the byteorder when arr is 
>> non-native byteorder ?
>>
>> If not, what functions does ?
>>   
> 
> It can if you pass in a data-type with the right byteorder (or use a 
> native built-in data-type).
> 
> In NumPy, it's the data-type that carries the "byte-order" 
> information.    So, there are lot's of ways to "fix" the byte-order.
> 
So then the question is: what is the easiest way to say:
give me the equivalent type of dtype, but with byteorder '<' (or '=') !?
I would be cumbersome (and ugly ;-) ) if one would have to "manually 
assemble" such a construct every time ...

> Of course there is still the difference between "fixing" the byte-order 
> and simply "viewing" the memory in the correct byte-order.  The former 
> physically flips bytes around, the latter just flips them on calculation 
> and presentation.
I understand. I need something that I can feed into my C routines that 
are to dumb to handle non-contiguous or byte-swapped data .

- Sebastian




More information about the NumPy-Discussion mailing list