Visitar URL original
Remove broken PySequence_Fast() function from the limited C API · Issue #55 · capi-workgroup/decisions · GitHub
Skip to content

Remove broken PySequence_Fast() function from the limited C API #55

Closed

Description

@vstinner

The limited C API has the function PySequence_Fast() which should be used with these macros:

  • PySequence_Fast_GET_SIZE()
  • PySequence_Fast_GET_ITEM()
  • PySequence_Fast_ITEMS()

Problem: none of these 3 macros work with the limited C API. The whole PySequence_Fast() API is broken in the limited C API.

Example:

#define PySequence_Fast_GET_ITEM(o, i)\
     (PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))

PyList_GET_ITEM() and PyTuple_GET_ITEM() are not part of the limited C API, so PySequence_Fast_GET_ITEM() cannot be used in the limited C API.

I propose to remove PySequence_Fast() and these 3 macros from the limited C API, since they are incompatible and never worked with the limited C API.

Vote:

Activity

  1. serhiy-storchaka commented on Jan 29, 2025

    @serhiy-storchaka

    I support this. It is clear to me that they were not excluded from the limited C API due to oversight.

    PySequence_ITEM also slipped in the limited C API. It was excluded in issue python/cpython#77919 (PR python/cpython#7477).

  2. encukou commented on Jan 30, 2025

    @encukou
    Collaborator

    +1 for removing the macros; yes, they never worked in limited API (and since PEP 652 they were never “officially” part of limited API); moving them to Include/cpython is the right thing to do.

    The PySequence_Fast function itself works. Third-party code can, theoretically, require a result of PySequence_Fast as input.
    If y'all think it should go I won't block the removal, but I think it's unnecessary. As minor, benign mistake of the past, it doesn't need fixing.

  3. vstinner commented on Jan 30, 2025

    @vstinner
    Author
  4. vstinner commented on Feb 2, 2025

    @vstinner
    Author

    Thanks for voting. I close the issue.

    @encukou:

    Third-party code can, theoretically, require a result of PySequence_Fast as input.
    If y'all think it should go I won't block the removal, but I think it's unnecessary.

    At least, the function remains available in the stable ABI.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions