我想检查python中int数据类型的大小:import syssys.getsizeof(int)结果是“ 436”,对我来说这没有意义。无论如何,我想知道我的机器将占用多少个字节(2,4,..?)int。
3 回答

慕的地6264312
TA贡献1817条经验 获得超6个赞
这是12个字节-在我的情况下是24个字节。Python int与c中的int非常不同。在Python中,an int
是成熟的对象。这意味着有额外的开销。请参阅此处,详细了解(cpython)int
内部。

慕码人2483693
TA贡献1860条经验 获得超9个赞
另外,这种描述的结构PyObject_HEAD
,你的链接上面的页面中看到宏。除了其他存储空间外,每个Python对象还至少包含一个引用计数和对该对象类型的引用。
添加回答
举报
0/150
提交
取消