bpo-38206: Clarify tp_dealloc requirements for heap allocated types. by ammaraskar · Pull Request #16248 · python/cpython
I agree that using the stable ABI is good, and we all migrate to it eventually. However, it's orthogonal to this change, which is about making the documentation correct. Pushing a stable ABI agenda in a fix for "Clarify that tp_dealloc must decref for heap allocated type" seems too sneaky for me – even though I count myself as a proponent of the stable ABI :)
In CPython, PyType_GetSlot is likely* much slower than using the slot directly, so it is not a clear win.
I'm for avoiding direct slot access (both in stdlib and extension modules), but only after a wider discussion and perhaps after also adding a fast (and unstable) API.
And again: the text above talks about PyTypeObject.tp_free. The example is confusingly out of sync with that. I think we should change both occurences, but please, do it in a different PR.
- (I haven't measured, but there's a bunch of extra checks in CPython's
PyType_GetSlot)