-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type slots are not extensible #13
Comments
Isn't this a fundamental constraint of the C language? How would you go about fixing any of this? |
Well, it's a problem, so it goes in this repo :) The current implementation hits constraint of the C language. With a better API, it wouldn't have to. For example: Leave the slots (and the whole type struct) out of the public API. Now we need to define getters and setters instead of direct struct access (which is a general theme around these parts). This leaves out one use case: people use stuff like |
Ah, got it. You don't want to get rid of slots altogether, you want to get them out of the public API. I agree with that. Also the observation that you don't need getters but callers is useful. |
We already have I think setters are less interesting because I don't think we want to mutate type objects after they've been initialised. A final bullet for the OP could be:
|
If slots with new signatures have new names, we could still have Mutating objects after initialization is necessary: you can do it in Python, so at least |
... as long as |
If we're replacing direct access to the type struct with setter functions, we get to ensure that. |
Agreed that this is a problem. Passing (class) context into slot functions would be helpful. |
Proposed “revolution” solution: capi-workgroup/api-revolution#4 (As I hinted above, I have a different approach to flesh out and propose, but will focus on “evolution” for the time being.) |
Type slot functions (
tp_new
,nb_add
) have fixed signatures, which makes it impossible to pass extra context. In particular__class__
cell, so you can't easily emulatesuper
in heap types.tp_getattro
was added,tp_getattr
was kept around, complicating inheritance.The text was updated successfully, but these errors were encountered: