mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -227,14 +227,8 @@ static int converters_init(PyObject* module)
|
|||
static int
|
||||
load_functools_lru_cache(PyObject *module)
|
||||
{
|
||||
PyObject *functools = PyImport_ImportModule("functools");
|
||||
if (functools == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pysqlite_state *state = pysqlite_get_state(module);
|
||||
state->lru_cache = PyObject_GetAttrString(functools, "lru_cache");
|
||||
Py_DECREF(functools);
|
||||
state->lru_cache = _PyImport_GetModuleAttrString("functools", "lru_cache");
|
||||
if (state->lru_cache == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue