On 16.06.2020 01:02, Victor Stinner wrote:
I created https://bugs.python.org/issue40989 to remove _Py_NewReference() and _Py_ForgetReference() from the public C API. I already started the work in Python 3.9 with:
commit f58bd7c1693fe041f7296a5778d0a11287895648 Author: Victor Stinner vstinner@python.org Date: Wed Feb 5 13:12:19 2020 +0100
bpo-39542: Make PyObject_INIT() opaque in limited C API (GH-18363) In the limited C API, PyObject_INIT() and PyObject_INIT_VAR() are now defined as aliases to PyObject_Init() and PyObject_InitVar() to make their implementation opaque. It avoids to leak implementation details in the limited C API.
Le lun. 15 juin 2020 à 22:43, M.-A. Lemburg mal@egenix.com a écrit :
If we can have PyObject_Del() always call _Py_ForgetReference() (and making sure that this is safe when the two obj links are NULL), the _Py_ForgetReference() could be made completely internal.
PyObject_Del() is just an alias to PyObject_Free() memory allocator function. It just frees memory, nothing more:
#define PyObject_Del PyObject_Free
Changing PyObject_Del() behavior is likely to break tons of C extension modules and cause issues with the stable ABI.
You could just as well add the call to _Py_ForgetReference() to PyObject_Free(). The point here is that _Py_ForgetReference() cleans up an internal linked list used for tracing, so not affect any external code.
I don't know where this resistance to make *any* changes in this respect is coming from, when at the same time you are making lots of other breaking changes to other parts of the C API.
This change would make the C API better, safer and remove the need to have to call _Py_ForgetReference() outside the interpreter.
Could you please explain ?
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Experts (#1, Jun 16 2020)
Python Projects, Coaching and Support ... https://www.egenix.com/ Python Product Development ... https://consulting.egenix.com/
::: We implement business ideas - efficiently in both time and costs :::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 https://www.egenix.com/company/contact/ https://www.malemburg.com/