Skip to content

Remove unused _PyArg_VaParseTupleAndKeywordsFast() #107196

Description

@vstinner

It seems like the _PyArg_VaParseTupleAndKeywordsFast() function is no longer used in the Python code base.

Moreover, Argument Clinic (Tools/clinic/clinic.py) can produce code calling the _PyArg_ParseTupleAndKeywordsFast() function, but it is not the case currently: _PyArg_ParseStackAndKeywords() is used instead.

What's the status of these two functions, _PyArg_ParseStackAndKeywords() and _PyArg_VaParseTupleAndKeywordsFast()?

cc @erlend-aasland @serhiy-storchaka

Linked PRs

Activity

  1. added 2 commits that reference this issue on Jul 24, 2023
  2. vstinner commented on Jul 24, 2023

    @vstinner
    MemberAuthor

    PR #107197 is the easy part: remove the unused private _PyArg_VaParseTupleAndKeywordsFast() function.

  3. serhiy-storchaka commented on Jul 25, 2023

    @serhiy-storchaka
    Member

    Argument Clinic currently unrolls parsing functions, generating a sequence of converter calls for individual parameters. But it does not support all cases, and when it fail to generate parsing code for all parameters, it falls back to traditional method, calling _PyArg_ParseTupleAndKeywordsFast or _PyArg_ParseStackAndKeywords. The former is used for __new__ and init`, the latter for other methods.

    So it happened that _PyArg_ParseTupleAndKeywordsFast is not used in currently generated code. But it will be used if we convert to Argument Clinic some classes with constructors which need it.

    _PyArg_VaParseTupleAndKeywordsFast is not used and AFAIK never was used. It was added for symmetry, for the case if we make this interface public.

    You can remove _PyArg_VaParseTupleAndKeywordsFast, but itself it will not save much code. You can defer this until we remove also _PyArg_ParseTupleAndKeywordsFast (and possible _PyArg_ParseStackAndKeywords) by ensuring that Argument Clinic no longer needs such fallback. Or until we add them (reworked) to the public API, so they could be used without Argument Clinic.

  4. added a commit that references this issue on Jul 27, 2023
  5. changed the title [-]Argument Clinic: is _PyArg_ParseTupleAndKeywordsFast() still used or not?[/-] [+]Remove unused _PyArg_ParseTupleAndKeywordsFast()[/+] on Jul 27, 2023
  6. changed the title [-]Remove unused _PyArg_ParseTupleAndKeywordsFast()[/-] [+]Remove unused _PyArg_VaParseTupleAndKeywordsFast()[/+] on Jul 27, 2023
  7. vstinner commented on Oct 17, 2023

    @vstinner
    MemberAuthor

    Let's keep _PyArg_ParseStackAndKeywords() for now. PR #110966 moves it to the internal C API, so it will be easier to remove it later if needed.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions