-
Notifications
You must be signed in to change notification settings - Fork 1
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
Define guideline for parameter types: PyObject vs specific type #29
Comments
IMO, we should continue to use XXX: To me, In a future API layer I'd love to switch to concrete types, but that's for the |
I think this is only because of static type definitions? If we'd had heap types from the start, we'd likely have made them |
While I know that it's not shared opinion, but in the long term, I would prefer to only use one type for all object arguments: Issues with using other types was discussed in PR python/cpython#106005. |
Since we're supposed to decide this in this tracker, let's use this issue to debate it instead of linking to other issues (we should considered the "problems" repo closed at this point -- we will soon be able to read all about it in PEP 733). I agree that in the evolutionary development of the C API we should stick to In the radical department we could possibly do this differently, but I personally would prefer not to -- however, I'll debate that when we get to it in capi-workgroup/api-revolution#3. |
No, it's also lots of functions like I'm fine sticking to What does this mean for type checking? Should API |
Here I'm talking about the hypothetical case of "opaque types" just to explain my point, but I'm not really arguing to move towards that or not here. It's just to consider all cases.
On the API side, we can keep In C, it's perfectly fine to define a type with an undefined structure: My argument here is more the desire for the long term to remove members from structures, but keep type names. Example: using Well, making If we change So I think that we should consider multiple things:
The consistency concern was discussed when adding a new PyDict_GetItemRef() API. Mark Shannon asked to use |
Another data point: PEP 670 – Convert macros to functions in the Python C API was approved with Avoid the cast in the limited C API version 3.11:
It means that APIs which take As @encukou wrote, I think that in practice, In the non-limited API, there are multiple APIs which accept "any type" (such as Example from Python code base: obj->lru_list_elem_type = (PyTypeObject*)Py_NewRef(state->lru_list_elem_type); Input: Between you and me, I would prefer to use |
I opened #27 for opaque structs (and also the structs that aren't opaque). Let's keep this issue about And yes, guidelines should be about new API. You're right that we can't really change existing API. |
I meant that those functions used If we'd used the time machine on this one, they probably would've been
I also agree. All our deliberately public APIs should be Footnotes |
Sounds good. New API should use |
See python/devguide#1127 issue.
See also capi-workgroup/problems#31 issue.
The text was updated successfully, but these errors were encountered: