pyo3
pyo3 copied to clipboard
Contribution opportunity: use Python 3.12 managed dict and weakref
In Python 3.12 type flags were added to make the interpreter automatically handle __dict__ and weakrefs for classes: https://docs.python.org/3.12/c-api/typeobj.html#c.Py_TPFLAGS_MANAGED_DICT
We should be able to switch to these instead of using out own dict_offset and weaklist_offset machinery. It's probably better for performance, and in the long run this would be a nice simplification to the codebase.
May I have a look into this?
Please do, as far as I know nobody else has suggested they have availability to try this.