[Python-Dev] Rename Include/internals/ to Include/pycore/ (original) (raw)
Benjamin Peterson benjamin at python.org
Sun Oct 28 16:40:07 EDT 2018
- Previous message (by thread): [Python-Dev] Rename Include/internals/ to Include/pycore/
- Next message (by thread): [Python-Dev] Rename Include/internals/ to Include/pycore/
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Oct 28, 2018, at 09:20, Victor Stinner wrote:
Hi,
Python C API has no strict separation between the 3 levels of API: * core: PyBUILDCORE define * stable: PyLIMITEDAPI define (it has a value) * regular: no define IMHO the current design of header files is done backward: by default, everything is public. To exclude an API from core or stable, "#ifdef PyBUILDCORE" and "#ifndef PyLIMITEDAPI" are used. This design caused issues in the past: functions, variables or something else exposed whereas they were supposed to be "private". I propose a practical solution for that: Include/*.h files would only be be public API. The "core" API would live in a new subdirectory: Include/pycore/*.h. Moreover, files of this subdirectory would have the prefix "pycore". For example, Include/objimpl.h would have a twin: Include/pycore/pycoreobjimpl.h which extend the public API with "core" APIs. I also propose to automatically load the twin: Include/objimpl.h would load Include/pycore/pycoreobjimpl.h if PyBUILDCORE is defined: #ifdef PyBUILDCORE # include "pycore/pycoreobjimpl.h" #endif
I don't think more or less API should be magically included based on whether Py_BUILD_CORE is defined or not. If we want to have private headers, we should include them where needed and not install them. Really, Py_BUILD_CORE should go away. We should be moving away from monolithic includes like Python.h to having each C file include exactly what it uses, private or not.
- Previous message (by thread): [Python-Dev] Rename Include/internals/ to Include/pycore/
- Next message (by thread): [Python-Dev] Rename Include/internals/ to Include/pycore/
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]