Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2021
Merged

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

merged 1 commit into from
Apr 21, 2021

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