Saturday, February 5, 2022

May be Rust can speed Django projects ?

I was trying to plugin pyo3 build Rust '.so' files(dynamic libraries) to Django. Looks like its not that difficult, we can copy and paste the file to Django folder. Once the file avaliable in Django folder , it will allow us to import the Rust dynamic library functions to your Django views.

Step1: create the Rust program as library using pyo3 and build the file using cargo build. Remember to put the crate-type "cdylib". I used manual build and copy .so file . Remember to keep the python module name and .so file name as same. https://pyo3.rs/v0.15.1/
Step2 Create your normal Django helloworld App
Step3 Copy the .so file to your Django project folder and import it in your views.py file, then you should be able to run django server .