在python的源代码中,有一些宏定义是这样的:
#define PyObject_HEAD \
int ob_refcnt; \
struct _typeobject *ob_type;
#define PyObject_VAR_HEAD \
PyObject_HEAD \
int ob_size;
typedef struct _object {
PyObject_HEAD
} PyObject;
typedef struct _object {
PyObject_HEAD
long ob_ival;
} PyIntObject;
typedef struct {
PyObject_VAR_HEAD
} PyVarObject;
问题是,为什么 PyObject* 可以指向 python 中的每个对象(如 PyIntObject、PyVarObject)?