python的None对象为什么是16字节?
In [64]: sys.getsizeof(None)
Out[64]: 16
Bing说:
The size of the None object in Python is 16 bytes 1. This is because Python uses a fixed-size object allocation mechanism for small objects like None 2. The size of the memory allocated is determined by the size of the object. For example, the size of the None object is 16 bytes, so Python pre-allocates 16 bytes of memory for each None object 2. This mechanism is used to improve performance by reducing the overhead associated with allocating and deallocating memory for small objects 3.
但感觉没有说透。https://github.com/python/cpython/blob/4abfe6a14b5be5decbaa3142d9e2549cf2d86c34/Doc/c-api/none.rst#L3 也没有直观的答案。似乎只有一个PyObject指针。
Python pre-allocates 16 bytes of memory for each None object 在哪里控制的?