-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Argument Clinic includes internal headers in generated output unconditionally #107603
Comments
'unconditionally' was a bit harsh, but it does generate core includes for some cases where it is not needed. |
I don't think this is an important issue, this is more of a "nice to have" rather than necessary, it will probably add more conditional code. I certainly don't consider this as a bug though. |
Yeah, it's not an important issue. But/feature? I'd say it is an undesirable feature, then :) |
Remove _PyLong_UnsignedShort_Converter() from the public C API: move the function to the internal pycore_long.h header. * Add Clinic.add_include() method * Add CConverter.include and CConverter.add_include() * Printer.print_block() gets a second parameter: clinic.
* Add Clinic.add_include() method * Add CConverter.include and CConverter.add_include() * Printer.print_block() gets a second parameter: clinic. * Remove duplicated declaration of "clinic" global variable.
I would like this feature to be able to remove private functions only used by AC from the public C API: issue #106320. |
* Add Clinic.add_include() method * Add CConverter.include and CConverter.add_include() * Printer.print_block() gets a second parameter: clinic. * Remove duplicated declaration of "clinic" global variable.
* Add Clinic.add_include() method * Add CConverter.include and CConverter.add_include() * Printer.print_block() gets a second parameter: clinic. * Remove duplicated declaration of "clinic" global variable.
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. Add Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/grpmodule.c * Modules/syslogmodule.c
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. Add Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/grpmodule.c * Modules/syslogmodule.c
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. Add Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/grpmodule.c * Modules/syslogmodule.c
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. Add Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/_testinternalcapi.c * Modules/grpmodule.c * Modules/syslogmodule.c On Windows, the _testinternalcapi extension is built as a shared extension which cannot use the _Py_ID() API: accessing _PyRuntime members is not possible in a static _PyArg_Parser variable, it's not a "constant".
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. Add Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/_testinternalcapi.c * Modules/_testmultiphase.c * Modules/grpmodule.c * Modules/syslogmodule.c On Windows, the _testinternalcapi and _testmultiphase extensions are built as shared extensions which cannot use the _Py_ID() API. Accessing _PyRuntime members is not possible in a static _PyArg_Parser variable, it's not a "constant".
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. Add Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/_testinternalcapi.c * Modules/_testmultiphase.c * Modules/grpmodule.c * Modules/syslogmodule.c * PC/_testconsole.c On Windows, the _testinternalcapi, _testmultiphase and _testconsole extensions are built as shared extensions which cannot use the _Py_ID() API. Accessing _PyRuntime members is not possible in a static _PyArg_Parser variable, it's not a "constant".
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. Add Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI macro to opt-out for the internal C API in Argument Clinic. The following extensions avoids the internal C API by defining the macro Py_ARGUMENT_CLINIC_AVOID_INTERNAL_CAPI: * Modules/_csv.c * Modules/_multiprocessing/posixshmem.c * Modules/_testcapi/exceptions.c * Modules/grpmodule.c * Modules/syslogmodule.c
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. * Add 'condition' optional argument to Clinic.add_include(). * deprecate_keyword_use() includes pycore_runtime.h when using the _PyID() function. * Fix rendering of includes: comments start at the column 35. Effects: * 42 header files generated by AC no longer include the internal C API, instead of 4 header files before. For example, Modules/clinic/_abc.c.h no longer includes the internal C API. * Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h to get _Py_ID().
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. * Add 'condition' optional argument to Clinic.add_include(). * deprecate_keyword_use() includes pycore_runtime.h when using the _PyID() function. * Fix rendering of includes: comments start at the column 35. * Mark PC/clinic/_wmimodule.cpp.h and "Objects/stringlib/clinic/*.h.h" header files as generated in .gitattributes. Effects: * 42 header files generated by AC no longer include the internal C API, instead of 4 header files before. For example, Modules/clinic/_abc.c.h no longer includes the internal C API. * Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h to get _Py_ID().
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. * Add 'condition' optional argument to Clinic.add_include(). * deprecate_keyword_use() includes pycore_runtime.h when using the _PyID() function. * Fix rendering of includes: comments start at the column 35. * Mark PC/clinic/_wmimodule.cpp.h and "Objects/stringlib/clinic/*.h.h" header files as generated in .gitattributes. Effects: * 42 header files generated by AC no longer include the internal C API, instead of 4 header files before. For example, Modules/clinic/_abc.c.h no longer includes the internal C API. * Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h to get _Py_ID().
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. * Add 'condition' optional argument to Clinic.add_include(). * deprecate_keyword_use() includes pycore_runtime.h when using the _PyID() function. * Fix rendering of includes: comments start at the column 35. * Mark PC/clinic/_wmimodule.cpp.h and "Objects/stringlib/clinic/*.h.h" header files as generated in .gitattributes. Effects: * 42 header files generated by AC no longer include the internal C API, instead of 4 header files before. For example, Modules/clinic/_abc.c.h no longer includes the internal C API. * Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h to get _Py_ID().
Is there more to do for this, or can the issue be closed? |
There might be room for improvement: the Argument Clinic now generates While there is room for improvement, I close the issue: further changes can be done in a even more specific issue. |
It seems like Argument Clinic generates code that define
Py_BUILD_CORE
and includes internal headers unconditionally; for example, a file with aMETH_O
function will have no need for those:OTOH, a
METH_KEYWORDS
function needs those:Argument Clinic should check if those defines/includes are needed before generating the output.
Linked PRs
print_block()
#108581The text was updated successfully, but these errors were encountered: