GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-108494: Argument Clinic partial supports of Limited C API by vstinner · Pull Request #108495 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Aug 25, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Argument Clinic now has a partial support of the
Limited API:

  • Add --limited option to clinic.c.
  • Add '_testclinic_limited' extension which is built with the limited C API version 3.13.
  • For now, hardcode in clinic.py that "_testclinic_limited.c" targets the limited C API.
  • Issue: Add support for the limited C API to Argument Clinic #108494

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-108494: Argument Clinic partial supports of Limited C API
d1f9bed
Argument Clinic now has a partial support of the
Limited API:

* Add --limited option to clinic.c.
* Add '_testclinic_limited' extension which is built with
  the limited C API version 3.13.
* For now, hardcode in clinic.py that "_testclinic_limited.c" targets
  the limited C API.
@vstinner
vstinner requested review from AlexWaygood and erlend-aasland as code owners August 25, 2023 20:42
@bedevere-bot bedevere-bot mentioned this pull request Aug 25, 2023
Add support for the limited C API to Argument Clinic #108494
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Aug 25, 2023
@vstinner

vstinner commented Aug 25, 2023

Copy link
Copy Markdown
Member Author

cc @erlend-aasland @AlexWaygood

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Fix make regen-stdlib-module-names
c2ebc65
@vstinner

vstinner commented Aug 25, 2023

Copy link
Copy Markdown
Member Author

Add '_testclinic_limited' extension which is built with the limited C API version 3.13.

Adding _testclinic_limited.my_int_func() was made possible by the addition of the PyLong_AsInt() to the public C API yesterday 😇 Well, later we can consider adding support for limited C API version 3.12 and older by adding a different code path. But having PyLong_AsInt() helps to have a bare minimum starting point for this work.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit 1dd9510 into python:main Aug 25, 2023
@bedevere-bot bedevere-bot removed the awaiting core review label Aug 25, 2023
@vstinner
vstinner deleted the clinic_limited branch August 25, 2023 21:22
@vstinner vstinner mentioned this pull request Aug 25, 2023
[C API] Convert a few stdlib extensions to the limited C API (PEP 384) #85283
Closed
vstinner
vstinner commented Aug 25, 2023
View reviewed changes
Comment thread Tools/clinic/clinic.py
*,
verify: bool = True,
output: str | None = None
ns: argparse.Namespace,

@vstinner vstinner Aug 25, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm replying here since I dislike comments lost on a commit, I don't think that many people will notice it.

I'm fine with people doing reviews after I merged changes (I like them!).

@AlexWaygood wrote:

I don't like this at all :(

Requiring that an argparse.Namespace object be passed to parse_file() feels like we're coupling the parse_file() function to the specific context in which it's currently called. A Namespace object is essentially unstructured data; we should be parsing the Namespace object in run_clinic(), and passing only the specific variables we need to parse_file(). Apart from anything else, this makes the code much less type-safe.

Free feel to change it in a follow-up PR. Your rationale makes sense and I don't have a strong preference for passing arguments here. Or I can do it if you prefer.

I'm still struggling a lot with this code base and I tried to write the minimum working change without touching too many parts of the code. The problem is that I'm not used with the AC design, so I'm not sure if it's the right place to add code...

I'd appreciate if you'd give me a day or so to review Argument Clinic PRs @vstinner — I didn't see the review request for this one until it was already merged :)

I understand your frustration. I didn't expect any review at all in fact. I'm always happy to get reviews, even if it's after I merge my change.

Today I wanted to push multiple changes to unblock my work on removing private functions: see PR #108499 which kind-of the end of my "PR serie".

I'm frequently frustrated by the fact that GitHub doesn't let me create a "patch serie" (multiple PRs depending on each others). So I have to merge my changes one by one, but I'm always bitten by a CI which dislike my change, then I have to wait 30 min for the next issue... On the AC changes, I didn't expect that make check-c-globals would fail for example.

I wanted to push the basis on AC work to add #include and to support the limited C API. For following changes, it should easier to work on multiple PRs at the same time.

I'm glad that other people are now working on AC. Adding #include and supporting the limited C API was a long awaited feature for me, I started working on that in 2020 :-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood reacted with heart emoji
All reactions
  • ❤️ 1 reaction

@vstinner vstinner Aug 26, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Follow-up PR: #108504

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood Aug 26, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm replying here since I dislike comments lost on a commit, I don't think that many people will notice it.

Oops, I didn't mean to add a comment on the commit — I meant to comment on the PR. Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@erlend-aasland erlend-aasland Aug 26, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I understand your frustration. I didn't expect any review at all in fact.

Come on, you know that both Alex and I are active on a daily basis on CPython ;)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@erlend-aasland
erlend-aasland requested a review from serhiy-storchaka August 26, 2023 06:24
@serhiy-storchaka

serhiy-storchaka commented Aug 26, 2023

Copy link
Copy Markdown
Member

I wish this change had not been made in rush.

First, the option should not be binary, it should specify the limited API version.

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed Aug 26, 2023
View reviewed changes
Comment thread Tools/clinic/clinic.py
{parse_arguments}))
goto exit;
""", indent=4)]
argname_fmt = 'args[%d]'

@serhiy-storchaka serhiy-storchaka Aug 26, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I do not think that it is correct. args is a Python tuple object here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Aug 26, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Oh ok, so I suppose that it can be removed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@erlend-aasland

erlend-aasland commented Aug 26, 2023

Copy link
Copy Markdown
Contributor

I wish this change had not been made in rush.

I agree. Either we revert the rushed changes, or we try to fix these things according to established workflow next week. cc. @vstinner @AlexWaygood

First, the option should not be binary, it should specify the limited API version.

That sounds like a better approach, indeed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Aug 26, 2023

Copy link
Copy Markdown
Member Author

See the related issue, we should be careful if we want to support older limited C API versions (really consider shipping binaries built with it and working on old Pytjon versions). There are many traps. The limited_capi type can be easily changed from bool and int.

Since AC and argument parsing are complex and I am trying to get this feature since 2020, I propose to have an incremental approach, have tests and move step by step. Having a full support of any code path in AC for the limited C API would be a giant work, I expect that it would be a giant PR really hard to review. Sadly, I'm not sure that the limited C API is complete enough to support all cases.

I added _testclinic_limited to check that the few formats already supported works as expected with functional tests.

If you prefer a different development method and restart from scratch, sure, go ahead and revert my changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland
erlend-aasland reviewed Aug 28, 2023
View reviewed changes
Comment thread Modules/_testclinic_limited.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@erlend-aasland erlend-aasland erlend-aasland left review comments
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@vstinner @serhiy-storchaka @erlend-aasland @AlexWaygood @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.