
On 06. 04. 22 9:23, Tim Felgentreff wrote:
Hi,
(I briefly commented also on the doc regarding this)
I’m probably misinterpreting the exact goals. I read “stable ABI for everyone” and I’m thinking “what needs to happen to stay binary compatible and working for a couple of decades at least”.
Well, the doc is more down to the ground than this thread can be :)
If that were the goal, I think the ideas around HPy’s handles and it’s usage of a context to get access to function pointers are most important, since that will ensure that new APIs can be added and old ones removed without breaking ABI. (This is very similar to how e.g. libraries like SDL deal with the problem that distributors want to update the SDL library and have it still work with 10 year old proprietary games).
In particular, even things like slots in types need to be opaque. An optimizing runtime may want to use varying layouts for both types and objects - allowing direct access into any runtime structures prevents that. Exposed structures should not be used for any runtime objects, only as specs for construction of those runtime objects.
With Python's current general API backwards compatibility policy (PEP 387), it wouldn't make much sense to make ABI guarantees that strong. In reality you're likely to get DeprecationWarnings and runtime exceptions, and will need to recompile extensions well before decades+-scale ABI incompatibilities hit you. IIUC, adopting HPy would break API: adding a context argument to all functions would would be so massive a change, it'd be easier to just call that HPy rather than Python C-API. And the doc I shared is for the C-API. (Perhaps CPython can even move to HPy and implement C-API as a veener on top -- but I don't think the original C-API can go away in our lifetimes.)