bpo-38353: Cleanup includes in the internal C API#16548
bpo-38353: Cleanup includes in the internal C API#16548vstinner merged 2 commits intopython:masterfrom vstinner:pathconfig
Conversation
Use forward declaration of types to avoid includes in the internal C API. Add also comment to justify other includes.
|
@brettcannon: Thanks for the review ;-) |
|
| #include "pycore_pystate.h" | ||
| #include "pythread.h" | ||
| /* Forward declarations */ | ||
| typedef struct pyruntimestate _PyRuntimeState; |
There was a problem hiding this comment.
The fact that 3 different headers need this same typedef makes me wonder if it might be worth having a short header called pycore_state_typedefs.h that was enough to allow declaration of APIs accepting state pointers, without needing to include the full state struct definitions.
Something like:
typedef struct _PyArgv _PyArgv;
typedef struct pyruntimestate _PyRuntimeState;
typedef struct _is PyInterpreterState;
struct _ceval_runtime_state;
Adding a new header file requires to modify the Unix (Makefile.pre.in) and the Windows (Visual Studio project files, at least 2 files) build systems. IMHO it's too annoying. I'm fine with duplicating these forward definitions. |
|
Hmm, I thought it was only new C files that were that annoying to add, but I admit it's been ages since I added a new header file. |
Use forward declaration of types to avoid includes in the internal C API. Add also comment to justify other includes.
Use forward declaration of types to avoid includes in the internal C
API. Add also comment to justify other includes.
https://bugs.python.org/issue38353