[Numpy-discussion] byte swap in place
Christopher Hanley
chanley at stsci.edu
Tue Jun 6 17:03:10 EDT 2006
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.
Example:
In [16]: a = n.array([1,2,3,4,5])
In [17]: a
Out[17]: array([1, 2, 3, 4, 5])
In [18]: b = a.byteswap()
In [19]: b
Out[19]: array([16777216, 33554432, 50331648, 67108864, 83886080])
In [20]: b[0] = 0
In [21]: b
Out[21]: array([ 0, 33554432, 50331648, 67108864, 83886080])
In [22]: a.dtype
Out[22]: dtype('<i4')
In [23]: b.dtype
Out[23]: dtype('<i4')
Thank you for your time and help,
Chris
More information about the NumPy-Discussion
mailing list