Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Re-work support of var-positional parameters in Argument Clinic #122943

Copy link
Copy link
@serhiy-storchaka

Description

@serhiy-storchaka
Issue body actions

When fixing some bugs (#118814, #122688) I noticed also design problems in _PyArg_UnpackKeywordsWithVararg().

  • Its vararg parameter is always equal to maxpos, therefore it is redundant.
  • Inserting a new tuple between values for positional and keyword-only parameters adds complexity in the _PyArg_UnpackKeywordsWithVararg() code which caused bugs.
  • Since it is the only argument value which is a strong reference, it adds complexity for cleanup after calling _PyArg_UnpackKeywordsWithVararg().
  • This large code is mostly a duplication of _PyArg_UnpackKeywords().
  • But it lacks some microoptimizations.
  • And produces wrong error messages in some corner cases.
  • Also some cases (like var-positional parameter after optional parameters) were not supported.

So I re-worked it in several steps:

  • Removed the vararg parameter from _PyArg_UnpackKeywordsWithVararg().
  • Moved creation of the tuple for var-positional parameter out from _PyArg_UnpackKeywordsWithVararg().
  • Refactored Argument Clinic code: it now generates similar code for var-positional parameter in functions with and without keyword parameters. The generated code is now more optimal and more cases are now supported. This is a large step.
  • Finally, _PyArg_UnpackKeywordsWithVararg() was merged with _PyArg_UnpackKeywords() which now got a new flag.

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.