[Python-Dev] Rename Include/internals/ to Include/pycore/ (original) (raw)
Victor Stinner vstinner at redhat.com
Sun Oct 28 12:23:08 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 ]
Oh, I forgot to add a reference to the bugs.python.org issue and my pull request!
My PR more or less implements the first milestone of my plan (Py_BUILD_CORE): it creates Include/pycore/.
Victor Le dim. 28 oct. 2018 à 17:20, Victor Stinner <vstinner at redhat.com> a écrit :
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 Only in some rare cases, you would have to explicitly use: #include "pycore/pycorepygetopt.h". This header is fully private, there is no public header in Include/pygetopt.h. Or maybe we should modify Include/Python.h to also include "pycore/pycorepygetopt.h" if PyBUILDCORE is defined? Well, that's just a detail. First milestone: * Create Include/pycore/ * Move PyBUILDCORE specific code into Include/pycore/pycore*.h * Automatically include pycore files from Include/*.h files (#ifdef PyBUILDCORE) Second milestone: * Find a solution for PyLIMITEDAPI :-) Backward compatibility? The overall change is fully backward compatible. The default API doesn't change. C code (using header fles) doesn't have to be changed. Only a specific kinds of applications like debugger may have to be modified if they really have to access the "core" API, the "most private" API. Honestly, today it's unclear to me if this API can technically be used outside CPython. Victor
- 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 ]