• Welcome to LusoRobótica - Robótica em Português.
 

Forma simples de estender Python com Rust.

Started by blabla, 06 de February de 2021, 09:04

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blabla

Bom dia,

Existem dois modos que podem ser utilizados para interligar Python e Rust.

Tanto se pode estender Python com módulos, funções e classes feitas em Rust e aproveitar por exemplo a performance muito superior do Rust single threaded ou multi-threaded para as partes mais criticas do nosso código Python em termos de performance. Como também se pode chamar código Python do Rust.

E por último também se pode fazer scripting em Python dos componentes feitos em Rust. Isto pode ser feito interligando com o CPython normal ou embebendo um interpretador de Python 3 feito em Rust dentro do nosso código Rust.

Python extended with Rust and running a Python interpreter inside Rust

PyO3 - GitHub
https://github.com/PyO3/pyo3

The PyO3 user guide - Book
https://pyo3.rs/master/

Python Extensions in Pure Rust with PyO3
https://depth-first.com/articles/2020/08/10/python-extensions-in-pure-rust-with-pyo3/

RustPython - A Python-3 interpreter written in Rust
https://github.com/RustPython/RustPython

Para toda esta informação sobre Rust e muito mais peço-vos que vejam o meu guia:

How to learn modern Rust
https://github.com/joaocarvalhoopen/How_to_learn_modern_Rust

Obrigado,

Cumprimentos,
João