feat(ffi): add Python 3.14 context watcher API#6204
Conversation
6535a6a to
5c25a54
Compare
|
This file should be moved to the cpython folder. To mirror upstream. |
|
This makes sense to me. Should i do it in this PR ? Or move it in a prior PR and then add the watcher API ? |
Yes please, you can do it here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed420e5f6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
The RustPython bindings still need to stay outside of the cpython module which is marked with Is this the correct approach in these cases ? |
RustPython only supports abi3/abi3t so these functions are not exposed. So you can remove all RustPython cfg attributes. |
da0c232 to
454b758
Compare
|
Thanks! LGTM |
|
As I don't have write access, please merge it when it makes sense. Thanks ! |
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks, looks correct to me with two small suggestions
| // Use the C enum's integer representation to permit future event values. | ||
| #[cfg(all(Py_3_14, not(any(PyPy, GraalPy))))] | ||
| pub type PyContextEvent = c_uint; | ||
|
|
||
| #[cfg(all(Py_3_14, not(any(PyPy, GraalPy))))] | ||
| pub const Py_CONTEXT_SWITCHED: PyContextEvent = 1; | ||
|
|
||
| #[cfg(all(Py_3_14, not(any(PyPy, GraalPy))))] | ||
| pub type PyContext_WatchCallback = | ||
| unsafe extern "C" fn(event: PyContextEvent, obj: *mut PyObject) -> c_int; |
There was a problem hiding this comment.
It would be great to have these definitions match the ordering in the 3.15 header please (i.e. they should come after PyContext_Exit)
There was a problem hiding this comment.
Makes sense. I reordered them in 25e6605. Thank you.
| @@ -0,0 +1 @@ | |||
| Add the Python 3.14 context watcher API to `pyo3-ffi`. | |||
There was a problem hiding this comment.
It would be great to list these directly; e.g. "Add FFI definitions PyContext_AddWatcher and PyContext_ClearWatcher on Python 3.14+"
There was a problem hiding this comment.
Agreed. I changed the note in commit 25e6605. Thank you.
Python 3.14 added a context watcher API for observing
contextvars.Contextswitches.This exposes the raw declarations in
pyo3-ffi.Relevant links: