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 — [C API] Make _PyTuple_FromArray() function public · Issue #111489 · python/cpython

[C API] Make _PyTuple_FromArray() function public #111489

New issue
Copy link
New issue
Copy link
Closed
Closed
[C API] Make _PyTuple_FromArray() function public#111489
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

@vstinner
vstinner
opened on Oct 30, 2023
Issue body actions

I dislike PyList_New() + PyList_SET_ITEM() API since the list is immediately tracked by the GC and so calling gc.get_objects() can expose an invalid list object (ex: calling repr(list) can crash). See:

  • Disallow creation of incomplete/inconsistent objects capi-workgroup/problems#56
  • gh-107137: Add _PyTupleBuilder API to the internal C API #107139
  • Avoid creating incomplete/invalid objects capi-workgroup/api-evolution#36

The internal PyObject * _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) function should be made public.

cc @erlend-aasland

UPDATE: I updated the issue to request promoting _PyTuple_FromArray() instead of _PyList_FromArraySteal().

Linked PRs

  • gh-111489: Add PyList_FromArrayMoveRef() function #112975
  • gh-111489: Add PyTuple_FromArray() function #139691
  • gh-111489: Remove _PyTuple_FromArray() alias #139973
Reacted by Erlend E. Aasland

Activity

  1. vstinner
    added
    topic-C-API
    on Oct 30, 2023
  2. vstinner commented on Oct 30, 2023

    @vstinner
    vstinner
    on Oct 30, 2023
    MemberAuthor
    More actions

    We should also make PyObject* _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n) public.

  3. encukou commented on Oct 30, 2023

    @encukou
    encukou
    on Oct 30, 2023
    Member
    More actions

    Can you wait until the new guidelines are approved? Not everyone is happy with the term steal.

  4. vstinner commented on Oct 30, 2023

    @vstinner
    vstinner
    on Oct 30, 2023
    MemberAuthor
    More actions

    Can you wait until the new guidelines are approved?

    The name is discussed at capi-workgroup/problems#11 (comment)

  5. vstinner commented on Dec 11, 2023

    @vstinner
    vstinner
    on Dec 11, 2023
    MemberAuthor
    More actions

    Naming is discussed at capi-workgroup/api-evolution#25

  6. vstinner
    added 4 commits that reference this issue on Dec 11, 2023

    pythongh-111489: Add PyList_FromArrayMoveRef() function

    0161a77

    pythongh-111489: Add PyList_FromArrayMoveRef() function

    c03ec75

    pythongh-111489: Add PyList_FromArrayMoveRef() function

    7b20ab0

    pythongh-111489: Add PyList_FromArrayMoveRef() function

    b12186e
  7. vstinner commented on Dec 20, 2023

    @vstinner
    vstinner
    on Dec 20, 2023
    MemberAuthor
    More actions

    @encukou:

    Can you wait until the new guidelines are approved?

    Ok, I close the issue.

  8. vstinner
    closed this as completedon Dec 20, 2023
  9. vstinner commented on Oct 7, 2025

    @vstinner
    vstinner
    on Oct 7, 2025
    MemberAuthor
    More actions

    Let me retry to implement these functions. I reopen the issue.

  10. vstinner
    reopened this on Oct 7, 2025
  11. vstinner
    added a commit that references this issue on Oct 7, 2025

    pythongh-111489: Add PyTuple_FromArray() function

    ce1b2ff
  12. vstinner commented on Oct 7, 2025

    @vstinner
    vstinner
    on Oct 7, 2025
    MemberAuthor
    More actions

    Let's start with the non controversial part: I created #139691 to add PyTuple_FromArray().

  13. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Oct 7, 2025
  14. vstinner commented on Oct 7, 2025

    @vstinner
    vstinner
    on Oct 7, 2025
    MemberAuthor
    More actions

    Naming is discussed at capi-workgroup/api-evolution#25

    I created capi-workgroup/decisions#78 to ask the C API Working Group to decide on the "take ownership" term (Steal or Move).

  15. vstinner
    changed the title [-][C API] Make _PyList_FromArraySteal() function public[/-] [+][C API] Make _PyList_FromArray() function public[/+] on Oct 9, 2025
  16. vstinner
    changed the title [-][C API] Make _PyList_FromArray() function public[/-] [+][C API] Make _PyTuple_FromArray() function public[/+] on Oct 9, 2025
  17. vstinner commented on Oct 10, 2025

    @vstinner
    vstinner
    on Oct 10, 2025
    MemberAuthor
    More actions

    Oh, the function _PyList_FromArraySteal() was replaced with _PyList_FromStackRefSteal() which gets a const _PyStackRef *src array (commit ab094d1).

  18. vstinner
    added a commit that references this issue on Oct 10, 2025

    gh-111489: Add PyTuple_FromArray() function (#139691)

    e31c22d
  19. vstinner commented on Oct 10, 2025

    @vstinner
    vstinner
    on Oct 10, 2025
    MemberAuthor
    More actions

    I close the issue.

    I added PyTuple_FromArray() to Python 3.15.

    The C API Working Group is against adding PyTuple_FromArraySteal() to the public C API.

  20. vstinner
    closed this as completedon Oct 10, 2025
  21. vstinner
    added 2 commits that reference this issue on Oct 11, 2025

    pythongh-111489: Remove _PyTuple_FromArray() alias

    eeb4532

    gh-111489: Remove _PyTuple_FromArray() alias (#139973)

    166cdaa
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.