-
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
Glossary for naming APIs #23
Comments
Re. capi-workgroup/problems#14 ( Avoid
If we were designing a new API, we could switch to |
@encukou what do you think about the guideline for Should PyO3 back up and reduce just back to |
I’m not Petr but I think that’s really up to PyO3. |
@gvanrossum fair point and I've intended to start a thread on this on the PyO3 issue tracker for a while. For what it's worth I was leaning towards I'll mark as off-topic. |
The question is off topic, but this discussion might be interesting for us as well. I've restored your comments. For any PyO3-specific follow-ups, your tracker is of course a better fit. Yup, it depends on the project. But PyO3 seems have a separate |
Should we prefer adding suffixes rather to using a different base name? E.g. should the "fixed" version of IMO, the suffix is uglier but clearer, and clarity wins that contest. |
Parts taken fromVictor's suffix survey: capi-workgroup/problems#52
We might want to provide a glossary to help keep API names consistent. Here's a draft.
Name components
From<type>
(e.g.PyLong_FromLong
): creates an objectAs<type>
(e.g.PyLong_AsLong
): converts to a C typeGet
: Retrieve a value (no side effect except allocation/refcounting)Va
: Takes varargsSuffixes
Object
(in functions, e.g. ): Takes a Python object rather than a native type (e.g.PyImport_AddModuleObject(PyObject*)
vs.PyImport_AddModule(char*)
)Object
(type, e.g.PyLongObject
): The instance struct. Omit the underscore (it's notPyLong_Object
)._<typename>
(_PyObject_CallFunction_SizeT
): Has an unexpected argument/return type, or a different type than a similar function_impl
: "Inner" function that has a wrapper. Used e.g. by Argument Clinic, and by C-specific speedups (Avoid macros and static inline functions #18). Should be marked private (_Py
) if exposed to users.Exceptions to rules
(These are new proposals)
Unchecked
: Doesn't validate a (pre)condition that's normally checkedUnsafe
: Doesn't uphold some invariant that users expectSuffixes for "evolved" versions of functions:
Ref
: Returns a new referenceWithError
: Has proper error handlingWith*
(WithKeywords
,WithBases
, etc.): Takes an additional argument.Flags
: Takes additional flagsEx
: Takes additional arguments. Avoid this; use a more specific name.XXX: Should we prefer adding these suffixes rather to using a different base name. (Should the "fixed" version of
PyDict_GetItem
bePyDict_GetItemRef
orPyDict_FetchItem
?) IMO, the suffix is uglier but clearer, and clarity wins that contest.Avoid
New
Fast
Ex
The text was updated successfully, but these errors were encountered: