它似乎不是处理器的“位数”(32 对 64),请参阅 this 上的评论发布,特别是:
Good answer. As I mentioned in my comments above, I'm able to duplicate @suzep136's issue on a Raspberry Pi 3, which uses a 64-bit ARM processor. Any idea why the overflow issue would occur on a 64-bit architecture? The only thing I can think of is that lapack/blas were compiled for a 32-bit core; I think I installed numpy through apt-get. – nrlakin
也不是 C 中 int 的大小,例如在我的机器上:
>>> import numpy, ctypes
>>>
>>> ctypes.sizeof(ctypes.c_int)
4
>>> numpy.array([1]).dtype
dtype('int64')
那么,它取决于什么?
编辑:还有另一位候选人,谢谢 ev-br:
LAPACK uses 32-bit integers on all architectures – ev-br
编辑:部分答案是 here .谢谢高洋。 我已经复制并制作了它 CW所以你可以添加更好的点,比如 PyPy 中发生的事情或杰通。我也很想知道这个选择是否有更深层次的原因。
最佳答案
感谢Goyo谁太谦虚了,不能把功劳占为己有。查看他们对相关但不同 question 的回答.
numpy 中的默认整数类型是 numpy.int_
,一定要注意结尾的下划线。它默认为 C long
1 .
关于python - 什么决定了 numpy 中 int 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41782767/