Python/Numpy:Numpy Unicode数组可以有多大?

2024-09-30 12:11:31 发布

您现在位置:Python中文网/ 问答频道 /正文

Numpy Unicode数组可以有多大

dtype = 'U100', 'U1000', 'U1000000'

我找不到有关文档的任何参考资料


Tags: 文档numpyunicode数组参考资料dtypeu1000u100
1条回答
网友
1楼 · 发布于 2024-09-30 12:11:31

我在https://numpy.org/doc/stable/reference/arrays.dtypes.html中找到了这一行:

Total dtype itemsize is limited to ctypes.c_int.

对于32位有符号整数,其值为2147483647。但实际上,项的字节大小也是有限的,因此除以4(Unicode代码点大小)就是2147483647 // 4或536870911

>>> import numpy as np
>>> np.array(['abcdef'],dtype='U536870911')
array(['abcdef'], dtype='<U536870911')
>>> np.array(['abcdef'],dtype='U536870911').itemsize
2147483644

此外:

dtype.itemsize

The element size of this data-type object.

For 18 of the 21 types this number is fixed by the data-type. For the flexible data-types, this number can be anything.

相关问题 更多 >

    热门问题