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 — Add public PyArg_ParseTupleAndKeywords API equivalent for METH_FASTCALL · Issue #144175 · python/cpython

Add public PyArg_ParseTupleAndKeywords API equivalent for METH_FASTCALL #144175

New issue
Copy link
New issue
Copy link
Closed
Closed
Add public PyArg_ParseTupleAndKeywords API equivalent for METH_FASTCALL#144175
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

Description

@rdb
rdb
opened on Jan 23, 2026
Issue body actions

Feature or enhancement

Proposal:

Opening an issue for this as requested by @vstinner in #110964.

METH_FASTCALL is part of the stable ABI as of Python 3.10. However, using it in extension module is quite difficult, because there is no equivalent API for PyArg_ParseTupleAndKeywords (which is the usual way to parse complex signatures with keywords in METH_VARARGS-style functions), and parsing vectorcall-style keywords is not a trivial problem to begin with. There used to be an undocumented public API (_PyArg_ParseStackAndKeywords) that solves this problem that is used by Argument Clinic, but it was removed from the public API as part of a wider effort to unexpose undocumented APIs in #110964.

So this issue requests a new public, stable API similar to PyArg_ParseTuple and PyArg_ParseTupleAndKeywords but accepting vectorcall-style parameters instead.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-144175: Add PyArg_ParseArray() function #144283
  • gh-144175: Remove internal _PyArg_ParseStack() function #159150

Activity

  1. rdb
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jan 23, 2026
  2. vstinner commented on Jan 23, 2026

    @vstinner
    vstinner
    on Jan 23, 2026
    Member
    More actions

    Python has a private API but this private API has been moved to the internal C API in Python 3.13:

    • _PyArg_BadArgument()
    • _PyArg_CheckPositional()
    • _PyArg_NoKeywords()
    • _PyArg_NoPositional()
    • _PyArg_ParseStack()
    • _PyArg_ParseStackAndKeywords()
    • _PyArg_Parser structure
    • _PyArg_UnpackKeywords()
    • _PyArg_UnpackKeywordsWithVararg()
    • _PyArg_UnpackStack()
    • _Py_ANY_VARARGS()
  3. vstinner commented on Jan 23, 2026

    @vstinner
    vstinner
    on Jan 23, 2026
    Member
    More actions

    The problem of _PyArg_ParseStackAndKeywords() is that it uses _PyArg_Parser structure which is complex to initialize.

    Example of code generated by Argument Clinic for _gdbm.gdbm.nextkey() function to parse a string (with its length):

        PyObject *return_value = NULL;
        #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
        #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
        #else
        #  define KWTUPLE NULL
        #endif
    
        static const char * const _keywords[] = {"", NULL};
        static _PyArg_Parser _parser = {
            .keywords = _keywords,
            .format = "s#:nextkey",
            .kwtuple = KWTUPLE,
        };
        #undef KWTUPLE
        const char *key;
        Py_ssize_t key_length;
    
        if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
            &key, &key_length)) {
            goto exit; 
        }
        Py_BEGIN_CRITICAL_SECTION(self);
        return_value = _gdbm_gdbm_nextkey_impl((gdbmobject *)self, cls, key, key_length);
        Py_END_CRITICAL_SECTION();
        
    exit:
        return return_value;
  4. vstinner commented on Jan 23, 2026

    @vstinner
    vstinner
    on Jan 23, 2026
    Member
    More actions

    cc @serhiy-storchaka

  5. StanFromIreland
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    topic-C-API
    on Jan 23, 2026
  6. vstinner
    added 2 commits that reference this issue on Jan 27, 2026

    pythongh-144175: Add PyArg_ParseVector() function

    b35a234

    pythongh-144175: Add PyArg_ParseVector() function

    769e40b
  7. vstinner commented on Jan 27, 2026

    @vstinner
    vstinner
    on Jan 27, 2026
    Member
    More actions

    I wrote #144283 to add PyArg_ParseVector() function: a first incomplete solution to this issue.

  8. vstinner
    pinned and unpinned a comment on Mar 6, 2026
  9. vstinner
    added a commit that references this issue on Mar 6, 2026

    gh-144175: Add PyArg_ParseArray() function (#144283)

    9159287
  10. vstinner commented on Mar 9, 2026

    @vstinner
    vstinner
    on Mar 9, 2026
    Member
    More actions

    Thanks for the report @rdb, it's now implemented in Python 3.15.

    I wrote #144283 to add PyArg_ParseVector() function: a first incomplete solution to this issue.

    The final change adds PyArg_ParseArray() and PyArg_ParseArrayAndKeywords(), so keywords are supported as well.

  11. vstinner
    closed this as completedon Mar 9, 2026
  12. rdb commented on Mar 10, 2026

    @rdb
    rdb
    on Mar 10, 2026
    Author
    More actions

    Thanks a lot!

    Reacted by Victor Stinner
  13. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-144175: Add PyArg_ParseArray() function (python#144283)

    4593b5d
  14. vstinner
    added a commit that references this issue on Oct 12, 2026

    gh-144175: Remove internal _PyArg_ParseStack() function (#159150)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.