On 08. 09. 21 17:21, Victor Stinner wrote:
On Wed, Sep 8, 2021 at 3:49 PM Petr Viktorin firstname.lastname@example.org wrote:
I converted Py_TYPE() and Py_SIZE() macros to static inline functions in the future Python 3.11. It's a backward incompatible change. For example, "Py_TYPE(obj) = type;" must be replaced with "Py_SET_TYPE(obj, type);".
Why is this needed?
Read the issue for the rationale: https://bugs.python.org/issue39573#msg361513
So, this is still only needed for experiments like tagged pointers or specialized lists.
I don't think it's needed to change API for these experiments. You need to convert any extensions that you use in benchmarking, and build them with an experimental Python. But I think we should only force the change on users if the experiment turns out successful.
It also looks useful for other APIs like HPy, and the situation is similar:
- projects that want to support the other API can change
- proponents of the other API can submit PRs for projects they need
To get those PRs merged, it would help if we officially document that assigning to Py_TYPE/Py_SIZE is discouraged. I'm all for that. But I don't see how the cost of disallowing it entirely, and forcing all users to adapt *now*, justifies the benefits.
I see it's been a draft for 2 years; are you still planning to actually submit it?