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

Context argument #2

Open
encukou opened this issue Oct 9, 2023 · 0 comments
Open

Context argument #2

encukou opened this issue Oct 9, 2023 · 0 comments

Comments

@encukou
Copy link

encukou commented Oct 9, 2023

New API functions should take a "context" as a first argument -- similar to PyThreadState * that a lot of current internal API takes, except opaque.

In the future, this should allow:

  • hopefully, a regular function argument will be easier to handle for future exotic platforms (the next Wasm)
  • run-time flag to enable debug checks (with a HPy-style function table)
  • prviding a limited context for destructors (so they can't run arbitrary Python code)

Functions that don't take a context argument should those that are safe to use before Python is initialized. (These e.g. PyStatus rather than exception objects for error handling.)

Current API that doesn't do this will need to call PyThreadState_Get before calling the new API.

@gvanrossum gvanrossum transferred this issue from capi-workgroup/api-evolution Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant