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
It is common (more than 30 cases) in the C code to access a function or a variable from other module. For example:
functools = PyImport_ImportModule("functools"); if (!functools) goto error; st->partial = PyObject_GetAttrString(functools, "partial"); Py_CLEAR(functools);
I propose to add a private helper function which combines PyImport_ImportModule() and PyObject_GetAttrString().
PyImport_ImportModule()
PyObject_GetAttrString()
st->partial = _PyImport_GetModuleAttrString("functools", "partial");
It will save 4-6 lines of code and a variable on every use.
The text was updated successfully, but these errors were encountered:
pythongh-93741: Add private C API _PyImport_GetModuleAttrString()
619cba1
It combines PyImport_ImportModule() and PyObject_GetAttrString() and saves 4-6 lines of code on every use.
Successfully merging a pull request may close this issue.
It is common (more than 30 cases) in the C code to access a function or a variable from other module. For example:
I propose to add a private helper function which combines
PyImport_ImportModule()andPyObject_GetAttrString().It will save 4-6 lines of code and a variable on every use.
The text was updated successfully, but these errors were encountered: