Tin mới
The object’s memory must be deallocated using PyObject_GC_Del().
Analogous to PyObject_GC_New but allocates extra_size bytes at the end of the object (at offset tp_basicsize). The allocated memory is initialized to zeros, except for the Python object header.
A typical tp_traverse function calls the Py_VISIT() convenience macro on each of the instance’s members that are Python objects that the instance owns. For example, this is a (slightly outdated) traversal function for th
gc: Interface to the cycle-detecting garbage collector.
The Py_VISIT() call may be skipped for those members that provably cannot participate in reference cycles. In the local_traverse example above, there is also a self->key member, but it can only be NULL or a Python string
The following functions should only be used in a tp_traverse handler; calling them in other contexts may have unintended consequences.
PyObject_GetTypeData(), PyObject_GetItemData(), PyType_GetModuleState(), PyModule_GetState(), PyModule_GetToken(), PyType_GetBaseByToken()
Perform a full garbage collection, if the garbage collector is enabled. (Note that gc.collect() runs it unconditionally.)