New-C-API-for-Python icon indicating copy to clipboard operation
New-C-API-for-Python copied to clipboard

Design type creation API

Open encukou opened this issue 1 year ago • 10 comments

Type creation is a pain point in the current Limited API. (The problems are systemic -- module spec has similar issues -- but they're most visible there & a solution should be applicable elsewhere.) The initial description -- PyType_Spec now and “layout and inheritance description” in https://github.com/markshannon/New-C-API-for-Python/issues/2#issuecomment-1222184913 -- can't easily be extended. The current extension mechanism, slots, is not type-safe. Adding methods and properties to a live class (my interpretation of Mark's “current thinking” in the linked issue) means modifying a possibly-immutable class, a no-no as it could invalidate useful invariants.

We could have an opaque “configuration” object that's allocated and configured using functions, with a “finalize” function that turns it into a class. Not sure about performance and other implications there.

encukou avatar Aug 22 '22 11:08 encukou