Skip to content

Remove unused _PyArg_VaParseTupleAndKeywordsFast() #107196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vstinner opened this issue Jul 24, 2023 · 3 comments
Closed

Remove unused _PyArg_VaParseTupleAndKeywordsFast() #107196

vstinner opened this issue Jul 24, 2023 · 3 comments
Labels
topic-argument-clinic topic-C-API type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

vstinner commented Jul 24, 2023

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

@vstinner vstinner added the type-bug An unexpected behavior, bug, or error label Jul 24, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Jul 24, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Jul 24, 2023
Remove the private _PyArg_VaParseTupleAndKeywordsFast() function: it
is no longer used.
@vstinner
Copy link
Member Author

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

@serhiy-storchaka
Copy link
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.

vstinner added a commit that referenced this issue Jul 27, 2023
)

Remove the private _PyArg_VaParseTupleAndKeywordsFast() function: it
is no longer used.
@erlend-aasland erlend-aasland changed the title Argument Clinic: is _PyArg_ParseTupleAndKeywordsFast() still used or not? Remove unused _PyArg_ParseTupleAndKeywordsFast() Jul 27, 2023
@erlend-aasland erlend-aasland changed the title Remove unused _PyArg_ParseTupleAndKeywordsFast() Remove unused _PyArg_VaParseTupleAndKeywordsFast() Jul 27, 2023
@vstinner
Copy link
Member Author

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
Labels
topic-argument-clinic topic-C-API type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants