【发布时间】:2019-03-12 20:08:36
【问题描述】:
小代码:
import sys
x = True
print(sys.getsizeof(x))
Python 2 输出:
24
Python 3 输出:
28
为什么getsizeof() 的输出在 Python 2 和 Python 3 中的函数不同?
【问题讨论】:
-
因为
True在内存中的大小在 Python 3 中似乎大了 4 个字节。
标签: python python-3.x python-2.7 boolean sizeof