Skip to content

yannickperrenet/max-rust-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calling Rust from Python

Quick exploration of using Rust for extending Python packages.

Timings

See test.py.

I felt it was interesting to compare different implementations of taking the maximum value of an array. Some in Python and some through Rust.

Python max():      0.085s
Python for-loop:   0.161s
Rust max():        1.361s
Rust 'do nothing': 1.228s
Rust actual max(): 0.133s
Rust pyarrow:      0.359s

Note, calculating the maximum value in Rust is slow because the array data has to be converted and copied.

Running it yourself

python -m venv venv
source venv/bin/activate
maturin develop
python test.py

Tools used

Helpful resources

About

Using Rust to extend Python packages

Topics

Resources

Stars

Watchers

Forks