Rust vs. C for Python Libraries: Evaluating Rust-Compatible Bindings Toolchains

📅 2025-06-30
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Python interpreter performance bottlenecks hinder critical-path optimization, while traditional C-based extensions (e.g., ctypes, cffi) suffer from high development complexity and memory unsafety. Method: This paper presents the first systematic evaluation of Rust—via the PyO3 binding framework—for developing native Python extensions, benchmarking its runtime performance, development effort, and maintainability against ctypes and cffi on identical workloads. Contribution/Results: PyO3 achieves near-C execution speed while preserving full CPython ABI compatibility and drastically reducing memory-safety vulnerabilities. Its declarative API simplifies binding generation, cutting source code volume by ~40% and improving compilation and debugging efficiency. Empirical results demonstrate that PyO3 delivers a compelling trade-off among safety, performance, and engineering practicality—establishing Rust as a viable, and often preferable, alternative to C for high-performance Python extension development.

Technology Category

Application Category

📝 Abstract
The Python programming language is best known for its syntax and scientific libraries, but it is also notorious for its slow interpreter. Optimizing critical sections in Python entails special knowledge of the binary interactions between programming languages, and can be cumbersome to interface manually, with implementers often resorting to convoluted third-party libraries. This comparative study evaluates the performance and ease of use of the PyO3 Python bindings toolchain for Rust against ctypes and cffi. By using Rust tooling developed for Python, we can achieve state-of-the-art performance with no concern for API compatibility.
Problem

Research questions and friction points this paper is trying to address.

Evaluating Rust vs. C for Python library performance
Comparing PyO3 bindings with ctypes and cffi toolchains
Achieving high performance without API compatibility issues
Innovation

Methods, ideas, or system contributions that make the work stand out.

Evaluates PyO3 Rust bindings for Python
Compares ctypes and cffi toolchains
Ensures API compatibility with Rust
🔎 Similar Papers
No similar papers found.
I
Isabella Basso do Amaral
University of São Paulo
R
Renato Cordeiro Ferreira
University of São Paulo, Jheronimus Academy of Data Science
Alfredo Goldman
Alfredo Goldman
Associate Professor of Computer Science, University of São Paulo
HPCDistributed SystemsAgile MethodsTechnical Debt