[Numpy-discussion] byte swap in place
Robert Kern
robert.kern at gmail.com
Tue Jun 6 17:33:38 EDT 2006
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
More information about the NumPy-Discussion
mailing list