> Guido, would you be agreeable to making this magic even more magical? It > seems to me that we can know whether the current type intends to participate > in cyclic gc, and give it a correct default tp_free value instead if so. > The hairier type_new() function already has this extra level of > Py_TPFLAGS_HAVE_GC-dependent magic for dynamically created types, setting > tp_free to PyObject_Del in one case and to PyObject_GC_Del in the other. > PyType_Ready() can supply a wrong deallocation function by default > ("explicit is better than implicit" has no force when talking about > PyType_Ready() <wink>). Yes, I think this is the right thing to do -- either only inherit tp_free when the GC bit of the base and derived class are the same, or -- in addition -- special case inheriting PyObject_Del and turn it into PyObject_GC_Del when the base class adds the GC bit. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4