Description
There have been long discussions on Discourse about how to go about dealing with C API changes, deprecations, private vs. public and ABI stability promises.
I think it's time to sit down and have a workgroup discuss and design the way forward. My hope is that this repo can turn into that workgroup, but we'd need some form of governance, regular meetings and deliverables for this to work out.
In any case, looking at the C API as it stands now, I find that (or perhaps I'm looking in the wrong places):
- there are many useful APIs which are marked private, but would be of benefit for extension writers; most of these APIs do not expose significant CPython internals which would hinder future developments
- we have no good C APIs for bulk operations (e.g. encode this list of 100k strings) or bulk methods in general
- the often heard suggestion to access CPython details by going via Python's lookups and function/method instead of using direct C APIs is not a universal answer in all situations; this works if you only need the information or action a few times, but completely fails when running in tighter loops; we need direct C APIs for often needed details
- more recently, the code base was changed to only allow upfront configuration of the interpreter(s); while this makes setting up interpreters easier, we lost the possibility to enable or change certain settings while the interpreter is running; we will need APIs to reenable making such online changes, e.g. to enable/disable optimization, the verbose flag or the dont-write-bytecode flag to name a few
- the C API should regain consistency by e.g. making the Unicode implementation encoder API public again (these used to be public in Python 2, albeit with a different signature)
I'm not a fan of redesigns, but instead would like to see the C API evolve over time and if this takes longer, that's perfectly fine.
There aren't all that many places which really expose internals in a way which hinders future development, e.g. APIs targeting the VM. Those can be treated with different strategies, while clearly stating our goals and promises we make.
For most other APIs, it's important to make the C API enjoyable for C programmers (again), providing a rich API with good tooling to tap into Python objects in an efficient way. This is what attracted me to Python back in 1994, when I was mostly a C programmer, and I would like Python to regain this elegance on the C side of things.