Python源码阅读(二、对象)

 

一、参考

Python源码剖析

 

二、正文

 

// 路径: Include\object.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;

 

// 路径:Include\object.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; // 类型信息

 

posted @ 2020-10-09 13:48  一曲广陵散yz  阅读(90)  评论(0编辑  收藏  举报