summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-04-21 22:52:52 (GMT)
committerGitHub <noreply@github.com>2021-04-21 22:52:52 (GMT)
commitcdad2724e6f7426372901cc5dedd8a462ba046a6 (patch)
treeca6a34bfdc6c05ea86d2ff2686ebd116750b2305 /setup.py
parenta32f8fe7133aad4f3cf8946534e3b79a5f2659da (diff)
downloadcpython-cdad2724e6f7426372901cc5dedd8a462ba046a6.zip
cpython-cdad2724e6f7426372901cc5dedd8a462ba046a6.tar.gz
cpython-cdad2724e6f7426372901cc5dedd8a462ba046a6.tar.bz2
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.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index af38440..df434d4 100644
--- a/setup.py
+++ b/setup.py
@@ -869,7 +869,8 @@ class PyBuildExt(build_ext):
#
# array objects
- self.add(Extension('array', ['arraymodule.c']))
+ self.add(Extension('array', ['arraymodule.c'],
+ extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
# Context Variables
self.add(Extension('_contextvars', ['_contextvarsmodule.c']))
@@ -934,9 +935,11 @@ class PyBuildExt(build_ext):
self.add(Extension("_asyncio", ["_asynciomodule.c"],
extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
# _abc speedups
- self.add(Extension("_abc", ["_abc.c"]))
+ self.add(Extension("_abc", ["_abc.c"],
+ extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
# _queue module
- self.add(Extension("_queue", ["_queuemodule.c"]))
+ self.add(Extension("_queue", ["_queuemodule.c"],
+ extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
# _statistics module
self.add(Extension("_statistics", ["_statisticsmodule.c"]))
@@ -2696,7 +2699,8 @@ def main():
'install_lib': PyBuildInstallLib},
# The struct module is defined here, because build_ext won't be
# called unless there's at least one extension module defined.
- ext_modules=[Extension('_struct', ['_struct.c'])],
+ ext_modules=[Extension('_struct', ['_struct.c'],
+ extra_compile_args=['-DPy_BUILD_CORE_MODULE'])],
# If you change the scripts installed here, you also need to
# check the PyBuildScripts command above, and change the links