mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742)
It combines PyImport_ImportModule() and PyObject_GetAttrString() and saves 4-6 lines of code on every use. Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
This commit is contained in:
parent
7b2064b4b9
commit
6fd4c8ec77
24 changed files with 114 additions and 248 deletions
|
|
@ -8279,11 +8279,7 @@ wait_helper(PyObject *module, pid_t pid, int status, struct rusage *ru)
|
|||
memset(ru, 0, sizeof(*ru));
|
||||
}
|
||||
|
||||
PyObject *m = PyImport_ImportModule("resource");
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
struct_rusage = PyObject_GetAttr(m, get_posix_state(module)->struct_rusage);
|
||||
Py_DECREF(m);
|
||||
struct_rusage = _PyImport_GetModuleAttrString("resource", "struct_rusage");
|
||||
if (struct_rusage == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue