Skip to content
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

Concrete types #3

Open
encukou opened this issue Oct 9, 2023 · 1 comment
Open

Concrete types #3

encukou opened this issue Oct 9, 2023 · 1 comment

Comments

@encukou
Copy link

encukou commented Oct 9, 2023

New API "layers" (#2, or a "C-API overhaul") should use concrete types, e.g. PyDictObject * rather than PyObject *.
Then we get type safety from the compiler, and we don't need type checking at runtime.

In the C-specific API, we'll want:

  • Simple upcasts (PyDictObjectPyObject) -- this is just a cast, but let's wrap it for type-safety
  • Fallible downcasts (PyObjectPyDictObject) -- a function that raises on bad type, and a function that
  • Possibly, if API functions autogenerated, we can use C++ overloads & C11 _Generic macros. That would allow taking either PyObject (and possibly raise) or the concrete type (with no overead).
@zooba
Copy link

zooba commented Oct 9, 2023

I'm -1 on this. I think it leads to massive API bloat and restricts our ability to innovate in the future.

I'm not saying our current system of runtime type checking is ideal, it could definitely use an overhaul, but I don't think pushing it into this layer is the right move.

@gvanrossum gvanrossum transferred this issue from capi-workgroup/api-evolution Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants