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-85283: Extending Argument Clinic to support to use the limited C API. #26080

Closed
wants to merge 1 commit into from

Conversation

shihai1991
Copy link
Member

@shihai1991 shihai1991 commented May 12, 2021

@shihai1991
Copy link
Member Author

shihai1991 commented May 12, 2021

python3 Tools/clinic/clinic.py --limited_api Modules/posixmodule.c

The test of Argument Clinic in: https://github.com/shihai1991/cpython/compare/main...shihai1991:clinic_support_limited_capi?expand=1

@shihai1991
Copy link
Member Author

@larryhastings Hi, Larry. Would you mind to take a look? cc @vstinner

@larryhastings
Copy link
Contributor

Before I look at the patch: what is the purpose of it? Argument Clinic is an internal tool for CPython, it can use the full API.

@shihai1991
Copy link
Member Author

shihai1991 commented May 14, 2021

Before I look at the patch: what is the purpose of it? Argument Clinic is an internal tool for CPython, it can use the full API.

Yes. The Argument Clinic can use the full API. So this PR add an option to allow developer to use the limited C API or not.
What's the benefit of using the limited C API? It can hide the implementation details of the C API and more easy to extend.

More details in:
PEP 620: https://www.python.org/dev/peps/pep-0620/#relationship-with-the-limited-c-api
some victor's comment: https://bugs.python.org/issue41111#msg372307

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jun 14, 2021
MaxwellDupre

This comment was marked as off-topic.

@@ -887,7 +895,7 @@ def parser_body(prototype, *fields, declarations=''):
""", indent=4)]
else:
parser_code = [normalize_snippet("""
if (!PyArg_ParseTuple(args, "{format_units}:{name}",
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Use the limited C API when using the use_limited_api flag, otherwise it'll use the unlimited C API.

Sorry for my delay.

else:
declarations = (
'static const char * const _keywords[] = {{{keywords} NULL}};\n'
'static _PyArg_Parser _parser = {{"{format_units}:{name}", _keywords, 0}};')
Copy link
Member

Choose a reason for hiding this comment

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

This is not in the Limited API.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, you are right. Thanks.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 7, 2022
@shihai1991 shihai1991 changed the title bpo-41111: Extending Argument Clinic to support to use the limited C API. gh-85283: Extending Argument Clinic to support to use the limited C API. Dec 18, 2022
@shihai1991
Copy link
Member Author

After PEP 620 canceled, so I decide close this PR. I will reopen this PR when we continue update PEP 620, ref: python/peps#2923
Thanks Mike, Serhiy for your review.

@shihai1991 shihai1991 closed this Dec 18, 2022
@CAM-Gerlach
Copy link
Member

@vstinner would of course know best, but my impression of the intent of withdrawing PEP 620 was that neither would it be re-opened and updated later or nor would the remaining changes be abandoned (as most of them were completed or mostly completed already), but rather they would be broken up into smaller separate PEPs.

@erlend-aasland
Copy link
Contributor

@shihai1991, are you interested in reviving this effort?

@shihai1991
Copy link
Member Author

shihai1991 commented Aug 4, 2023

@shihai1991, are you interested in reviving this effort?

Sure, of course. Sorry for my late replay ;)

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.

9 participants