Open question: Can we change the field type of PyTupleObject and PyListObject?

I want to change the PyObject ob_item fields in our list and tuple implementation to support tagged integers. This will involve changing their type (but not their field names nor their width).

The docs for PyListObject and PyTupleObject don’t say whether they’re part of the limited API or stable ABI. Tuple Objects — Python 3.15.0a0 documentation. So I’m confused.

To be clear: this change will NOT break PyTuple/List_GET_ITEM and related. It should just be an internal change, I’m just wondering if the fields and their types are considered public.

CC @vstinner @steve.dower @iritkatriel @encukou

They’re very much part of public API; PEP 387 applies to them. You could deprecate ob_item, add a replacement for it, and schedule it for removal when Python versions without the replacement go EOL. (The process allows a shorter/longer period than the default, but due to widespread usage and dangerous behaviour when misused, this one should probably be longer.)

The structures definitely aren’t part of the limited API/stable ABI so changing them won’t break that. (But as Petr says, they are used in regular API extensions)

Thanks to both of you. I think my question is answered: I can’t do it :slight_smile: .

2 Likes