From: Robert K. <rob...@gm...> - 2006-06-06 21:34:05
|
Christopher Hanley wrote: > Hi, > > Is there a way to byte swap a ndarray in place? The "byteswap" method I > have found on an ndarray object currently returns a new array. Depends. Do you want the actual bytes to swap, or are you content with getting a view that pretends the bytes are swapped? If the latter: >>> a = arange(5) >>> a.dtype dtype('>i4') >>> a.dtype = dtype('<i4') >>> a array([ 0, 16777216, 33554432, 50331648, 67108864]) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |