Skip to content
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

gh-130947: Add again PySequence_Fast() to the limited C API #130948

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Mar 7, 2025

Add again PySequence_Fast(), PySequence_Fast_GET_SIZE() and PySequence_Fast_GET_ITEM() to the limited C API

Add an unit tests.


📚 Documentation preview 📚: https://cpython-previews--130948.org.readthedocs.build/

Add again PySequence_Fast(), PySequence_Fast_GET_SIZE() and
PySequence_Fast_GET_ITEM() to the limited C API

Add an unit tests.
@vstinner
Copy link
Member Author

vstinner commented Mar 7, 2025

This PR basically does the opposite of PR #129398 which is part of Python v3.14.0a5 release. Instead of removing these APIs from the limited C API, this PR fixes the limited C API implementation of PySequence_Fast_GET_SIZE() and PySequence_Fast_GET_ITEM() macros, and it adds again PySequence_Fast() to the limited C API.

PySequence_Fast_ITEMS() remains removed, since this function should be implemented in the limited C API.

What changed since PR #129398 is that I discovered (via a bug report) that PyQt6 uses PySequence_Fast(). Moreover PyQt6 reimplements PySequence_Fast_GET_SIZE() and PySequence_Fast_GET_ITEM() macros in the limited C API.

cc @serhiy-storchaka @encukou

@serhiy-storchaka
Copy link
Member

This should be considered a new feature and discussed with the C API Workgroup. Also, I do not think that it is right to replace fast macros with slower functions.

@vstinner
Copy link
Member Author

vstinner commented Mar 7, 2025

Also, I do not think that it is right to replace fast macros with slower functions.

Fast macros are not replaced with slower functions. In the regular C API, this PR changes nothing. It only changes the limited C API implementation to use function calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants