- Create some trivial Rust extensions for Python included in the Python package
awesome-package
- Rust extensions include
hello_from_rust
and count_words_rust
.
- The Rust extensions reside under
src/lib.rs
- Corresponding Python-based versions (for comparison):
hello_from_python
and count_words_python
.
- Run
make
to build a Conda environment and install the Python package (thereby building the Rust extensions).
- This will create a Conda environment in the current directory named
.env
- After installation, activate the Conda environment via e.g.
conda activate ./.env
.
- Run
ipython
to start an IPython session and import from awesome_package
:
from awesome_package import count_words_rust, count_words_python
%timeit count_words_rust("<<path_to_file>>")
%timeit count_words_python("<<path_to_file>>")