GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing github.com — gh-107704: Argument Clinic: add support for deprecating keyword use of parameters by serhiy-storchaka · Pull Request #107984 · python/cpython Conversation
|
|
Do you want an initial review of the draft, or would you like to wait until it is marked ready for review? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I kept it in a draft state for the first run of tests and the final stage of self-review. It is now ready for review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it would be beneficial to try and reduce some of the code duplication, either in this PR, or in a following-up refactor. Perhaps the latter is preferable.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| if func.kind.new_or_init: | ||
| conditions.append(f"nargs < {i+1} && kwargs && PyDict_Contains(kwargs, &_Py_ID({p.name}))") | ||
| containscheck = "PyDict_Contains" | ||
| else: | ||
| conditions.append(f"nargs < {i+1} && kwnames && PySequence_Contains(kwnames, &_Py_ID({p.name}))") | ||
| containscheck = "PySequence_Contains" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it is the simplest general way to check that the argument was passed by keyword. It is not the fastest. For inlined parsing code we can use more efficient but more complex code, we can even build it in _PyArg_UnpackKeywords(). But if PyArg_ParseTupleAndKeywords() or similar function is used, the only other way is to use deprecated and inefficient PyMapping_HasKeyString() or introduce a new private inefficient API.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What's the concern with using _Py_ID() here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Currently, there is no concern; I just wanted to point out that even though Argument Clinic does not currently care about the Limited API, we may want to add such functionality in the future; IMO, it should be possible for Argument Clinic to generate code that does not depend on internal APIs, for example for stdlib extension modules such as sqlite3.
Many core devs seem to be in favour of not using internal APIs in stdlib extension modules, but I'm not sure if there is a consensus.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review @erlend-aasland. I tried to address them. Seems the only unresolved issue is with _Py_ID().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this, @serhiy-storchaka. @AlexWaygood, do you want to have a look?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Some small suggestions for the docs:
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, just a few very minor nits:
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review @AlexWaygood. Do these docstrings work?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @serhiy-storchaka!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Post-review changes:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…eyword use of parameters (python/cpython#107984) It is now possible to deprecate passing keyword arguments for keyword-or-positional parameters with Argument Clinic, using the new '/ [from X.Y]' syntax. (To be read as "positional-only from Python version X.Y") Co-authored-by: Erlend E. Aasland <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
…eyword use of parameters (python/cpython#107984) It is now possible to deprecate passing keyword arguments for keyword-or-positional parameters with Argument Clinic, using the new '/ [from X.Y]' syntax. (To be read as "positional-only from Python version X.Y") Co-authored-by: Erlend E. Aasland <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.