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:
Serhiy Storchaka 2022-06-14 07:15:26 +03:00 committed by GitHub
parent 7b2064b4b9
commit 6fd4c8ec77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 114 additions and 248 deletions

View file

@ -226,7 +226,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(_showwarnmsg)
STRUCT_FOR_ID(_shutdown)
STRUCT_FOR_ID(_slotnames)
STRUCT_FOR_ID(_strptime_time)
STRUCT_FOR_ID(_uninitialized_submodules)
STRUCT_FOR_ID(_warn_unawaited_coroutine)
STRUCT_FOR_ID(_xoptions)
@ -252,7 +251,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(difference_update)
STRUCT_FOR_ID(dispatch_table)
STRUCT_FOR_ID(displayhook)
STRUCT_FOR_ID(enable)
STRUCT_FOR_ID(encode)
STRUCT_FOR_ID(encoding)
STRUCT_FOR_ID(end_lineno)
@ -311,7 +309,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(opcode)
STRUCT_FOR_ID(open)
STRUCT_FOR_ID(parent)
STRUCT_FOR_ID(partial)
STRUCT_FOR_ID(path)
STRUCT_FOR_ID(peek)
STRUCT_FOR_ID(persistent_id)
@ -357,7 +354,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(warnoptions)
STRUCT_FOR_ID(writable)
STRUCT_FOR_ID(write)
STRUCT_FOR_ID(zipimporter)
} identifiers;
struct {
PyASCIIObject _ascii;

View file

@ -848,7 +848,6 @@ extern "C" {
INIT_ID(_showwarnmsg), \
INIT_ID(_shutdown), \
INIT_ID(_slotnames), \
INIT_ID(_strptime_time), \
INIT_ID(_uninitialized_submodules), \
INIT_ID(_warn_unawaited_coroutine), \
INIT_ID(_xoptions), \
@ -874,7 +873,6 @@ extern "C" {
INIT_ID(difference_update), \
INIT_ID(dispatch_table), \
INIT_ID(displayhook), \
INIT_ID(enable), \
INIT_ID(encode), \
INIT_ID(encoding), \
INIT_ID(end_lineno), \
@ -933,7 +931,6 @@ extern "C" {
INIT_ID(opcode), \
INIT_ID(open), \
INIT_ID(parent), \
INIT_ID(partial), \
INIT_ID(path), \
INIT_ID(peek), \
INIT_ID(persistent_id), \
@ -979,7 +976,6 @@ extern "C" {
INIT_ID(warnoptions), \
INIT_ID(writable), \
INIT_ID(write), \
INIT_ID(zipimporter), \
}, \
.ascii = { \
_PyASCIIObject_INIT("\x00"), \