Skip to content

Conversation

DinoV
Copy link
Contributor

@DinoV DinoV commented May 19, 2025

These APIs are used in CPython's interpreter loop. Alternate interpreter loops can be created using the cases_generator script with an additional input file that can be plugged in using PEP 523. But because these functions aren't exposed it's not possible to actually fully create these alternative interpreter loops without copying and pasting large amounts of code.

@DinoV DinoV requested a review from vstinner May 19, 2025 16:23
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it too much to ask for these to be renamed to PyUnstable?

@DinoV
Copy link
Contributor Author

DinoV commented May 19, 2025

Is it too much to ask for these to be renamed to PyUnstable?

I'm happy to defer on that, but would be fine renaming them if that seems better. But they're buried in the internal APIs and require defining Py_BUILD_CORE to use which means you're already taking a responsibility on if you want to use them. Also there are currently no PyUnstable functions declared at all in the internal header files (even though there are hundreds of exported functions).

@DinoV DinoV removed the needs backport to 3.14 bugs and security fixes label May 19, 2025
@vstinner
Copy link
Member

Is it too much to ask for these to be renamed to PyUnstable?

PyUnstable functions require documentation and tests.

Comment on lines +92 to +94
PyAPI_FUNC(PyObject *) _PyType_LookupSubclasses(PyTypeObject *);
PyAPI_FUNC(PyObject *) _PyType_InitSubclasses(PyTypeObject *);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a little off, putting the dict out there to be modified. What do you need this for, specifically? Can we provide some specific operation (like "set a dict watcher") rather than exposing the whole dict?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll drop this for now and come back and do a different PR that specifically addresses the classes. It seems like adding a whole new API for this is deserving of its own PR.

@DinoV DinoV force-pushed the expose_apis branch 7 times, most recently from 0c65264 to 42b861f Compare June 28, 2025 01:00
Copy link
Contributor

@itamaro itamaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are all in internal headers and _Py-prefixed, I think it's fairly clear they aren't public or supported API in any meaningful sense.

it seems rather arbitrary which APIs need to be exposed and which ones do not.
since the intent is to enable alternative loop generators, perhaps it's worth adding a test that covers this use-case? e.g., a test that generates and uses an alternative interpreter, that would fail if the interpreter starts using APIs that are not exposed.

@DinoV DinoV requested a review from mpage September 8, 2025 17:12
@picnixz picnixz changed the title gh-131776: Expose functions called from the interpreter loop via PyAP… gh-131776: Expose functions called from the interpreter loop via PyAPI_FUNC Sep 8, 2025
@mpage mpage requested a review from Yhg1s September 9, 2025 18:19
Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

If this were moving things to the public API it would be a different story, but it's not. :)

@DinoV DinoV merged commit 299de38 into python:main Sep 17, 2025
43 checks passed
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.

5 participants