Chapter 1-Python objects
All Python objects inherit from pyobject directly or indirectly. The definition of pyobject is simple:
Struct _ OBJECT {
Py_ssize_t ob_refcnt; // reference count
Struct pytypeobject * ob_type; // type object pointer
} Pyobject;
The reference count determines the survival of objects. Destroy object when ob_refcnt is 0
A member of a python object is a virtual function table in C ++.
Pytypeobject is also an object that inherits from pyobject. In addition to recording the object name, object size, and other data, it is a series of function pointers. Including how to reclaim the destructor of object memory, how to print objects, attribute-related functions, as well as numeric object (number) function system, sequence object function system, and ing object (mapping) functions. Set the function pointer value for different types of objects according to their own needs. For example, the integer object pyequalbject has only the number function, but not the sequence and mapping functions.