synapticarbors / rust-numba-test

Proof-of-concept of calling a Numba jit'd function from Rust from Python using CFFI
7 stars 1 forks source link

rust-numba-test

Proof-of-concept of calling a Numba jit'd function from Rust from Python using CFFI

This example defines a function in Rust that doubles the result of the function passed to it. The Numba @cfunc decorator with CFFI support requires Numba 0.27. This allows Numba to create a C callback that can be passed to Rust.

Basic instructions for running the example:

If you need to install numba, then I recommend first getting Miniconda and then:

conda create -n rust-numba-example cffi numba numpy
source activate rust-numba-example  # or just `activate rust-numba-example` on Windows

Then to compile the Rust code and run the python example:

cargo build --release
python test.py