| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… use of parameters 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")
|
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.
|
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 a problem hiding this comment.
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.
| 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.
Sorry, something went wrong.
There was a problem hiding this comment.
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 a problem hiding this comment.
Sorry, something went wrong.
There was a problem hiding this comment.
What's the concern with using _Py_ID() here?
Sorry, something went wrong.
There was a problem hiding this comment.
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 a problem hiding this comment.
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 a problem hiding this comment.
Thanks for doing this, @serhiy-storchaka. @AlexWaygood, do you want to have a look?
Sorry, something went wrong.
There was a problem hiding this comment.
Some small suggestions for the docs:
Sorry, something went wrong.
There was a problem hiding this comment.
Code looks good, just a few very minor nits:
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you for your review @AlexWaygood. Do these docstrings work?
Sorry, something went wrong.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
There was a problem hiding this comment.
LGTM. Thanks @serhiy-storchaka!
Sorry, something went wrong.
|
Post-review changes:
|
Sorry, something went wrong.
…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 <erlend@python.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…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 <erlend@python.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
| Back | FazBrowse Home | New Git URL |
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")