]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)
authorVictor Stinner <vstinner@python.org>
Wed, 21 Apr 2021 22:52:52 +0000 (00:52 +0200)
committerGitHub <noreply@github.com>
Wed, 21 Apr 2021 22:52:52 +0000 (00:52 +0200)
commitcdad2724e6f7426372901cc5dedd8a462ba046a6
treeca6a34bfdc6c05ea86d2ff2686ebd116750b2305
parenta32f8fe7133aad4f3cf8946534e3b79a5f2659da
bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)

Add pycore_moduleobject.h internal header file with static inline
functions to access module members:

* _PyModule_GetDict()
* _PyModule_GetDef()
* _PyModule_GetState()

These functions don't check at runtime if their argument has a valid
type and can be inlined even if Python is not built with LTO.

_PyType_GetModuleByDef() uses _PyModule_GetDef().

Replace PyModule_GetState() with _PyModule_GetState() in the
extension modules, considered as performance sensitive:

* _abc
* _functools
* _operator
* _pickle
* _queue
* _random
* _sre
* _struct
* _thread
* _winapi
* array
* posix

The following extensions are now built with the Py_BUILD_CORE_MODULE
macro defined, to be able to use the internal pycore_moduleobject.h
header: _abc, array, _operator, _queue, _sre, _struct.
21 files changed:
Include/internal/pycore_moduleobject.h [new file with mode: 0644]
Makefile.pre.in
Modules/Setup
Modules/_abc.c
Modules/_functoolsmodule.c
Modules/_operator.c
Modules/_pickle.c
Modules/_queuemodule.c
Modules/_randommodule.c
Modules/_sre.c
Modules/_struct.c
Modules/_threadmodule.c
Modules/_winapi.c
Modules/arraymodule.c
Modules/posixmodule.c
Objects/frameobject.c
Objects/moduleobject.c
Objects/typeobject.c
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
setup.py