On Mon, Jan 31, 2022 at 4:03 PM Petr Viktorin <encukou@gmail.com> wrote:
If we change the stable ABI, I would prefer to fix multiple issues at once. Examples:
* No longer return borrowed references (ex: PyDict_GetItem is part of the stable ABI) and no longer steal references (ex: PyModule_AddObject)
* Disallow getting direct access into an object data without a function to "release" the data. For example, PyBytes_AsString() gives a direct access into the string, but Python doesn't know when the C extension is done with it, and when it's safe to delete the object. Such API prevents to move Python objects in memory (implement a moving garbage collector in Python).
* Disallow dereferencing a PyObject* pointer: most structures must be opaque. It indirectly means that accessing directly structure members must also be disallowed. PEP 670 and PEP 674 are partially fixing the issues.
(...) fixing these in the API first is probably the way to go.
That's what I already did in the past and what I plan to do in the future. Victor -- Night gathers, and now my watch begins. It shall not end until my death.