Search notes:

CPython: Include/object.h

Object and type object interface

PyObject

PyObject stores an Python object's reference counter (ob_refcnt) and a type pointer (ob_type).
typedef struct _object {
    _PyObject_HEAD_EXTRA
    Py_ssize_t ob_refcnt;
    PyTypeObject *ob_type;
} PyObject;
If Py_TRACE_REFS is defined when compiing the sources, the macro _PyObject_HEAD_EXTRA is used to dfine a doubly-linked list of all live heap objects. If Py_TRACE_REFS is not defined, _PyObject_HEAD_EXTRA evaluates to nothing.

PyVarObject

typedef struct {
    PyObject ob_base;
    Py_ssize_t ob_size; /* Number of items in variable part */
} PyVarObject;

PyType_Slot

typedef struct{
    int slot;    /* slot id, see below */
    void *pfunc; /* function pointer */
} PyType_Slot;

PyType_Spec

typedef struct{
    const char* name;
    int basicsize;
    int itemsize;
    unsigned int flags;
    PyType_Slot *slots; /* terminated by slot==0. */
} PyType_Spec;

Links

Include/object.h on github

See also

Include/cpython/object.h

Index