PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Other
11.44k stars 693 forks source link

Contribution opportunity: use Python 3.12 managed dict and weakref #4253

Open davidhewitt opened 2 weeks ago

davidhewitt commented 2 weeks ago

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.