From: Travis O. <oli...@ie...> - 2006-08-11 20:02:34
|
Sebastian Haase wrote: > I just found this in myCVS/numpy/numpy/core/tests/test_numerictypes.py > <code> > > def normalize_descr(descr): > "Normalize a description adding the platform byteorder." > > return out > </code> > > Is that what I was talking about !? It's quite a big animal. > Would this be needed "everytime" I want to get a "systembyte-ordered version" > of a given type !? > No, I'm not even sure why exactly that was written but it's just in the testing code. I think the email I sent yesterday got lost because I sent it CC: numpy-discussion with no To: address. Here's what I said (more or less) in that email: You can use the .newbyteorder(endian='s') method of the dtype object to get a new data-type with a different byteorder. The possibilities for endian are 'swap', 'big' ('>'), 'little' ('<'), or 'native' ('='). This will descend down a complicated data-type and change all the byte-orders appropriately. Then you can use .astype(newtype) to convert to the new byteorder. The .isnative attribute of the data-type will tell you if the data-type (or all of it's fields in recent SVN) are in native byte-order. -Travis |