Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
I was planning to achieve this by converting the Python code to C code, with Cython, compile it and call the compiled functions on the Rust code. As far as I went seaching about it, it seems possible. Despite being a possible solution, this would be a hassle, this would be my first time using Cython and making a Rust bind to C code, so I tried to find an easier solution by trying to compile Python code to Rust code or something in this direction. I'm not sure if any of the projects I found would do what I'm looking for. I found RustPython, which has an experimental JIT that compile Python functions to native code but the usage is still in Python code, not in Rust code. Another project I saw was the ct_python which apparently Run's Python code at Rust compile time and replaces the ct_python! macro with the Python code output, that again doesn't match my intentions.
If the CPython interpreter is too heavy for you to embed, you may want to check out https://circuitpython.org/ which is designed for using Python on embedded devices
https://pyo3.rs is the most popular solution