Le 28/02/2019 à 20:09, Neil Schemenauer a écrit :
Here is a sketch of the API. Introduce a new, lower level API that works with object handles. Call them pyref_t. The object handle API doesn't implement reference counting. So, it is cheap for PyPy to implement it. Passing objects back and forth using the handle API is cheaper. To make it easy for existing extension modules or ones that want to use reference counting, provide a PyObject layer on top of the handle API. E.g.
pyref_t *r = pyref_some_api_that_opens_a_handle(); PyObject *o = PyObject_FromRef(r); Py_INCREF(o); Py_DECREF(o); Py_DECREF(o); // handle gets closed because refcnt goes to zero
The PyObject structure could be:
typedef struct { size_t refcnt; pyref_t *r; } PyObject;
Are you showing the PyPy implementation of PyObject?
To solve the non-opaque PyObject/PyTypeObject issue, I think you could have a source code option that turns on opaque types.
I don't understand what this means. Do you need a special CPython build with a different set of preprocessor options? Or is this when building an extension?
(if the latter, it sounds close to the existing "stable ABI")
Regards
Antoine.