|、> 和 < 在 numpy 数据类型中
|, > and < in numpy datatype
这可能是一个非常愚蠢的问题,但我尝试 google 关键字,如 less and greater signs in data type of numpy
,但没有找到任何参考。
在numpy
的doc中,
x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
产出
array([(1.0, 2), (3.0, 4)],
dtype=[('x', '<f8'), ('y', '<i4')])
但是在我的电脑上,输出是
array([(1.0, 2), (3.0, 4)],
dtype=[('x', '>f8'), ('y', '>i4')])
dtype
中的<
和>
是什么意思,为什么会有区别?
关键字 <
和 >
代表 byte ordering, aka endianness. It is the order in which bytes from numbers are stored (when numbers are compossed of more than 1 byte, e.g. int16, int32, float32...). This page from the reference 在 numpy 中为您提供了您需要的所有信息,但作为摘要:
|
:它没有字节顺序,因为它是多余的(在单字节数字或字符串上)
<
: 小端
>
: 大端
正如@tobias_k 和@RobertKern 指出的那样,默认 字节序,如果未指定,则取决于系统。
这可能是一个非常愚蠢的问题,但我尝试 google 关键字,如 less and greater signs in data type of numpy
,但没有找到任何参考。
在numpy
的doc中,
x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
产出
array([(1.0, 2), (3.0, 4)],
dtype=[('x', '<f8'), ('y', '<i4')])
但是在我的电脑上,输出是
array([(1.0, 2), (3.0, 4)],
dtype=[('x', '>f8'), ('y', '>i4')])
dtype
中的<
和>
是什么意思,为什么会有区别?
关键字 <
和 >
代表 byte ordering, aka endianness. It is the order in which bytes from numbers are stored (when numbers are compossed of more than 1 byte, e.g. int16, int32, float32...). This page from the reference 在 numpy 中为您提供了您需要的所有信息,但作为摘要:
|
:它没有字节顺序,因为它是多余的(在单字节数字或字符串上)<
: 小端>
: 大端
正如@tobias_k 和@RobertKern 指出的那样,默认 字节序,如果未指定,则取决于系统。