Rust is so fast, and python can leverage power of rust.
By the way, you know, python is too slow ??
This is not what proves that rust is better than cpp. Apparently, cpp(nanobind) is able to become even faster. [link]
$ git clone <repo> && cd <repo>
$ poetry install
$ poetry shell
$ cmake -S . -B build
$ cmake --build build
#############
# benchmark #
#############
$ python main.py --fibonacci 40
python : 21.961166224995395
python(numba) : 0.7921977119985968
python(numba-nopython): 0.7205598769942299
python(cython) : 0.6859547469939571
c++(nanobind) : 0.3306063709896989
rust(pyo3) : 0.21601284098869655- nanobind
$ pip install nanobind- edit CMakeLists.txt
- edit <file_name>.cpp
$ cmake -S . -B build$ cmake --build build
- pyo3
$ pip install maturin$ maturin new -b pyo3 rusty-python$ cd rusty-python- edit src/lib.rs
- and back to base directory of poetry
$ pip install ./rusty-python/
First of all, you need to identify bottlenecks using either of ways which cProfile, time.perfcounter(), %%timeit.
- improve time-complexity in terms of Big O Notation
- use multi thread or process
- use numpy?
- use PyPy
- use codon?