Hi.
I was really lazy but I'm happy to announce that PyO3 0.11.0 two weeks ago and released rust-numpy 0.11.0 this week, which are the first versions working with stable Rust toolchain!
PyO3 is an FFI library for interacting with the Python interpreter.
With PyO3, you can write Python extension in Rust, or call Python functions from Rust with or without embedding it in your binary.
You can also use ctypes or rust-cpython for this purpose, but I recommend PyO3 due to its easy-to-use proc-macro interface for defining new classes or functions, like:
#[pyclass]
struct FVec {
inner: Vec<f64>
}
#[pymethods]
impl MyExtensionClass {
#[new]
fn new() -> Self { ... }
fn add(&self, other: &Self) -> PyResult<Self> { ... }
}
My previous post is also referred for anyone curious.
PyO3 has been only for nightly toolchain for a long time because it used specialization, but we succeeded to replace relevant parts using ctor and inventory crates (i.e., now some ffi functions are registered dynamically by ctor, instead of resolved statically by specialization). I really appreciate @konstin for the initial idea and @davidhewitt for the detailed code review, as well as all contributors and users.
My biggest motivation for PyO3 was to make it as solid as its C++ counterparts (e.g., pybind11) and encourage people to migrate to Rust from C or C++.
So if you have a friend who is tired of writing C/C++ for Python extension, please recommend them to use Rust
It's good timing!