PyObject
from PythonのGC
すべての組み込み型の構造体は、先頭にPyObjectを持っている
中身
include/object.h
code:c
typedef struct _object {
_PyObject_HEAD_EXTRA
Py_ssize_t ob_refcnt; // 参照カウントを保持
struct _typeobject *ob_type; // 型の情報を保持
} PyObject;
Pythonのオブジェクトの構造
これらが各組み込み型に対応している
PyListObject: リスト型
PyTupleObject: タプル型
PyDictObject: 辞書型
PyFloatObject: 浮動小数点型
PyLongObject: 長整数型
https://docs.python.org/3.9/c-api/structures.html
https://postd.cc/python-internals-pyobject/