Skip to content
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

gh-107603: Argument Clinic: Only include pycore_gc.h if needed #108726

Merged
merged 5 commits into from
Aug 31, 2023

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Aug 31, 2023

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().
Tools/clinic/clinic.py Outdated Show resolved Hide resolved
Tools/clinic/clinic.py Outdated Show resolved Hide resolved
Tools/clinic/clinic.py Outdated Show resolved Hide resolved
Tools/clinic/clinic.py Outdated Show resolved Hide resolved
@vstinner
Copy link
Member Author

@AlexWaygood: Please review my updated PR. I addressed your latest review.

@erlend-aasland erlend-aasland changed the title gh-107603: AC only includes pycore_gc.h if needed gh-107603: Argument Clinic: Only include pycore_gc.h if needed Aug 31, 2023
Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't like to pass around clinic like that, but if Alex is fine with it, it's ok.

It is nice to avoid unneeded includes, so thanks for that clean-up.

@vstinner
Copy link
Member Author

I also don't like to pass around clinic like that, but if Alex is fine with it, it's ok.

In general, limited_capi bool is now passed as an argument. clinic is only passed as an argument when clinic.add_include() should be called.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I also don't like to pass around clinic like that

Yeah, agreed that this maybe isn't the best pattern, but we can always refactor at a later date — I think this is fine for now.

Thanks for the updates @vstinner!

@vstinner vstinner merged commit ad73674 into python:main Aug 31, 2023
25 checks passed
@vstinner vstinner deleted the clinic_includes3 branch August 31, 2023 21:42
@vstinner
Copy link
Member Author

Merged, thanks for reviews @AlexWaygood and @erlend-aasland!

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.

4 participants