Skip to content

Add PyList_GetItemRef, a variant of PyList_GetItem that returns a strong reference #114329

Description

@colesbury

Feature or enhancement

The free-threaded builds need a variant of PyList_GetItem that returns a strong reference instead of a borrowed reference for thread-safety reasons. PEP 703 proposed PyList_FetchItem, but since then PyDict_GetItemRef and functions with similar signatures have been added.

This proposes PyList_GetItemRef with the following signature:

PyObject *PyList_GetItemRef(PyObject *list, Py_ssize_t index)

Return a strong reference to the object at position index in the list pointed to by list. If index is out of bounds (<0 or >=len(list)), return NULL and set an IndexError. If list is not a list instance, return NULL and set a TypeError.

Linked PRs

Activity

  1. colesbury commented on Jan 19, 2024

    @colesbury
    ContributorAuthor

    C-API working group issue: capi-workgroup/decisions#9

  2. Eclips4 commented on Jan 19, 2024

    @Eclips4
    Member

    Just FYI, feature requests do not need version label :)

  3. added 2 commits that reference this issue on Jan 23, 2024
  4. added a commit that references this issue on Feb 2, 2024
  5. encukou commented on Feb 2, 2024

    @encukou
    Member

    Thank you!

  6. added a commit that references this issue on Feb 11, 2024
  7. added a commit that references this issue on Feb 14, 2024
  8. added 3 commits that reference this issue on Apr 3, 2024
  9. added a commit that references this issue on Apr 17, 2024
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