-
dtype.byteorder
-
A character indicating the byte-order of this data-type object.
One of:
?=? native ?<? little-endian ?>? big-endian ?|? not applicable All built-in data-type objects have byteorder either ?=? or ?|?.
Examples
12345678910111213141516171819202122>>> dt
=
np.dtype(
'i2'
)
>>> dt.byteorder
'='
>>>
# endian is not relevant for 8 bit numbers
>>> np.dtype(
'i1'
).byteorder
'|'
>>>
# or ASCII strings
>>> np.dtype(
'S2'
).byteorder
'|'
>>>
# Even if specific code is given, and it is native
>>>
# '=' is the byteorder
>>>
import
sys
>>> sys_is_le
=
sys.byteorder
=
=
'little'
>>> native_code
=
sys_is_le
and
'<'
or
'>'
>>> swapped_code
=
sys_is_le
and
'>'
or
'<'
>>> dt
=
np.dtype(native_code
+
'i2'
)
>>> dt.byteorder
'='
>>>
# Swapped code shows up as itself
>>> dt
=
np.dtype(swapped_code
+
'i2'
)
>>> dt.byteorder
=
=
swapped_code
True
dtype.byteorder

2025-01-10 15:47:30
Please login to continue.