Transpiling Python to Rust for Optimized Performance
Lunnikivi, Henri; Jylkkä, Kai; Hämäläinen, Timo (2020-10-07)
Lunnikivi, Henri
Jylkkä, Kai
Hämäläinen, Timo
07.10.2020
This publication is copyrighted. You may download, display and print it for Your own personal use. Commercial use is prohibited.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi:tuni-202101261718
https://urn.fi/URN:NBN:fi:tuni-202101261718
Kuvaus
Peer reviewed
Tiivistelmä
Python has become the de facto programming language in machine learning and scientific computing, but high performance implementations are challenging to create especially for embedded systems with limited resources. We address the challenge of compiling and optimizing Python source code for a low-level target by introducing Rust as an intermediate source code step. We show that pre-existing Python implementations that depend on optimized libraries, such as NumPy, can be transpiled to Rust semi-automatically, with potential for further automation. We use two representative test cases, Black–Scholes for financial options pricing and robot trajectory optimization. The results show up to 12× speedup and 1.5× less memory use on PC, and the same performance but 4× less memory use on an ARM processor on PYNQ SoC FPGA. We also present a comprehensive list of factors for the process, to show the potential for fully automated transpilation. Our findings are generally applicable and can improve the performance of many Python applications while keeping their easy programmability.
Kokoelmat
- TUNICRIS-julkaisut [19330]