Skip to content

bpo-40137: Add pycore_moduleobject.h internal header#25507

Merged
vstinner merged 1 commit intopython:masterfrom
vstinner:type_getmodulebyref5
Apr 21, 2021
Merged

bpo-40137: Add pycore_moduleobject.h internal header#25507
vstinner merged 1 commit intopython:masterfrom
vstinner:type_getmodulebyref5

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Apr 21, 2021

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.

https://bugs.python.org/issue40137

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.
@vstinner
Copy link
Member Author

test_ttk_guionly failed on the Ubuntu job of Azure Pipelines PR: unrelated to my PR.

@vstinner vstinner merged commit cdad272 into python:master Apr 21, 2021
@vstinner vstinner deleted the type_getmodulebyref5 branch April 21, 2021 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants