Should {tp_alloc, tp_dealloc} and {tp_new, tp_free} be considered as pairs?
问题 Is it true that whatever is created in tp_alloc should be destroyed in tp_dealloc? And similarly for {tp_new, tp_free}? It looks like an obvious symmetry, but I would be grateful for clarification. My actual use case is this: I have: class OSClass : PyObject {...} class Final : OSClass {...} So the corresponding PyTypeObject pto has: pto->tp_basicsize = sizeof(FinalClass) pto->tp_dealloc = (destructor) [](PyObject* pyob) { PyMem_Free(pyob); }; However the new style class stores the PyObject