Python源码阅读(二、对象)

 

一、参考

Python源码剖析

二、正文

// 路径: Includeobject.h
/*
Nothing is actually declared to be a PyObject, but every pointer to * a Python object can be cast to a PyObject*. This is inheritance built * by hand. Similarly every pointer to a variable-size Python object can, * in addition, be cast to PyVarObject*. */ typedef struct _object { PyObject_HEAD } PyObject;
// 路径:Includeobject.h
/*
PyObject_HEAD defines the initial segment of every PyObject. */ #define PyObject_HEAD _PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt; // 引用计数,用于内存管理 struct _typeobject *ob_type; // 类型信息
原文地址:https://www.cnblogs.com/thewindyz/p/13785415.html