Type Objects — Python 3.14.7 documentation

docs.python.org

Tin mới

Concrete Objects Layer

Python Module Index

3.14.7 Documentation

Python/C API reference manual

PyTypeObject.tp_flags

Return the tp_flags member of type. This function is primarily meant for use with Py_LIMITED_API; the individual flag bits are guaranteed to be stable across Python releases, but access to tp_flags itself is not part of

PyObject_GetAttr()

Return the type object’s internal namespace, which is otherwise only exposed via a read-only proxy (cls.__dict__). This is a replacement for accessing tp_dict directly. The returned dictionary must be treated as read-onl

__subclasscheck__()

This function only checks for actual subtypes, which means that __subclasscheck__() is not called on b. Call PyObject_IsSubclass() to do the same check that issubclass() would do.

PyObject_InitVar()

Generic handler for the tp_alloc slot of a type object. Uses Python’s default memory allocation mechanism to allocate memory for a new instance, zeros the memory, then initializes the memory as if by calling PyObject_Ini

PyObject_GC_NewVar

Generic handler for the tp_alloc slot of a type object. Uses Python’s default memory allocation mechanism to allocate memory for a new instance, zeros the memory, then initializes the memory as if by calling PyObject_Ini

PyModule_GetState()

Return the state of the module object associated with the given type. This is a shortcut for calling PyModule_GetState() on the result of PyType_GetModule().

method resolution order

Find the first superclass in type’s method resolution order whose Py_tp_token token is equal to the given one.

Weak Reference Objects

weakref: Support for weak references and weak dictionaries.

PyMemberDef documentation

Slot IDs are named like the field names of the structures PyTypeObject, PyNumberMethods, PySequenceMethods, PyMappingMethods and PyAsyncMethods with an added Py_ prefix. For example, use: