在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;
Run Code Online (Sandbox Code Playgroud)
问题是,为什么PyObject*可以指向python中的每个对象(例如PyIntObject,PyVarObject)?