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 — Document how to use varargs in Argument Clinic by skirpichev · Pull Request #1629 · python/devguide

Conversation

@skirpichev

@skirpichev skirpichev commented Aug 12, 2025 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

📚 Documentation preview 📚: https://cpython-devguide--1629.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@aisk @JelleZijlstra @skirpichev
Document how to use varargs in Argument Clinic
436be4a
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Sergey B Kirpichev <[email protected]>
@skirpichev
skirpichev requested a review from erlend-aasland August 12, 2025 11:38
@skirpichev

skirpichev commented Aug 12, 2025

Copy link
Copy Markdown
Member Author

This is a minor correction of closed pr #1277 (now var-positional arguments passed a C array). The rest looks fine for me.

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev skirpichev mentioned this pull request Aug 12, 2025
Argument Clinic should understand *args and **kwargs parameters python/cpython#64490
Closed
vstinner
vstinner reviewed Aug 13, 2025
View reviewed changes
Comment thread development-tools/clinic.rst Resolved

Uh oh!

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

@AA-Turner @skirpichev
Update development-tools/clinic.rst
16237b2
Co-authored-by: Sergey B Kirpichev <[email protected]>
AA-Turner
AA-Turner reviewed Aug 15, 2025
View reviewed changes
Comment thread development-tools/clinic.rst Resolved

Uh oh!

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

AA-Turner
AA-Turner reviewed Aug 15, 2025
View reviewed changes
Comment thread development-tools/clinic.rst Resolved

Uh oh!

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

@skirpichev @AA-Turner
Update development-tools/clinic.rst
816d5e8
Co-authored-by: Adam Turner <[email protected]>
skirpichev
skirpichev commented Aug 15, 2025
View reviewed changes
Comment thread development-tools/clinic.rst Resolved

Uh oh!

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

skirpichev
skirpichev commented Aug 15, 2025
View reviewed changes
Comment thread development-tools/clinic.rst Resolved

Uh oh!

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

@skirpichev
Apply suggestions from code review
18e9be6
AA-Turner
AA-Turner requested changes Aug 15, 2025
View reviewed changes

@AA-Turner AA-Turner left a comment

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.

We should mention both the tuple and array converters, they do different things. Notably array results in PyObject * const *args and Py_ssize_t args_length, whereas tuple just passes a regular PyTupleObject.

Also, I found the PR where : object was removed (python/cpython#126560 by @serhiy-storchaka)

Sorry, something went wrong.

Uh oh!

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

All reactions
@skirpichev
Mention tuple converter
1322930
@skirpichev

skirpichev commented Aug 16, 2025

Copy link
Copy Markdown
Member Author

Also, I found the PR where : object was removed

It's not removed, just an alias for tuple.

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev
skirpichev requested a review from AA-Turner August 16, 2025 01:48
AA-Turner
AA-Turner reviewed Aug 17, 2025
View reviewed changes
Comment thread development-tools/clinic.rst Outdated
Comment on lines +1498 to +1514
How to convert var-positional parameter functions
-------------------------------------------------

To convert a var-positional parameter function, prepend the parameter name
with ``*`` and use the the ``array`` converter.
For example::

/*[clinic input]
var_positional_sample

foo: int
*args: array
[clinic start generated code]*/

The implementation function will receive var-positional arguments as C array
*args* of :c:type:`PyObject * <PyObject>`. Alternatively, you could use
``tuple`` converter to pass a regular :c:type:`PyTupleObject` as argument.

@AA-Turner AA-Turner Aug 17, 2025

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.

A suggested rephrasing to split tuple and array. I've also switched to saying *args instead of emphasising var-positional, the documentation uses *args or starargs, when discussing the feature in the language reference, it seems to be only internal to Clinic to say varpos.

Suggested change
How to convert var-positional parameter functions
-------------------------------------------------
To convert a var-positional parameter function, prepend the parameter name
with ``*`` and use the the ``array`` converter.
For example::
/*[clinic input]
var_positional_sample
foo: int
*args: array
[clinic start generated code]*/
The implementation function will receive var-positional arguments as C array
*args* of :c:type:`PyObject * <PyObject>`. Alternatively, you could use
``tuple`` converter to pass a regular :c:type:`PyTupleObject` as argument.
How to convert ``*args`` parameters (starargs / var-positional)
---------------------------------------------------------------
There are two converters suitable for ``*args``: *array* and *tuple*.
Using the *array* converter will provide the implementation function with
a C array *args* of type of :c:type:`PyObject * <PyObject>` and the number
of items in the array as :c:type:`Py_ssize_t` *args_length*.
For example::
/*[clinic input]
var_positional_sample
spam: int
*args: array
[clinic start generated code]*/
Using the *tuple* converter will provide the implementation function with
a standard :c:type:`PyTupleObject`.
For example::
/*[clinic input]
var_positional_sample
spam: int
*args: tuple
[clinic start generated code]*/

Sorry, something went wrong.

Uh oh!

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

All reactions

@skirpichev skirpichev Aug 18, 2025

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.

IMO, it's too verbose. But OK.

Sorry, something went wrong.

Uh oh!

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

All reactions
@skirpichev @AA-Turner
Update development-tools/clinic.rst
5644df2
Co-authored-by: Adam Turner <[email protected]>
AA-Turner
AA-Turner approved these changes Aug 18, 2025
View reviewed changes
@AA-Turner
AA-Turner merged commit 25cb613 into python:main Aug 18, 2025
@skirpichev
skirpichev deleted the clinic-varpos branch August 18, 2025 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
@AA-Turner AA-Turner AA-Turner approved these changes
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland

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.

4 participants

@skirpichev @vstinner @AA-Turner @aisk
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 01402520 — 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.