Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 30, 2026·3 min de lecture

RustPython — Python Interpreter Written in Rust

A full Python 3 interpreter implemented in Rust, targeting WebAssembly, embedding, and educational use cases.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
RustPython Overview
Commande d'installation directe
npx -y tokrepo@latest install cf3a1fe0-5c01-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

RustPython is a Python 3 interpreter written entirely in Rust. It aims for full CPython compatibility while offering memory safety, easy embedding into Rust applications, and the ability to compile to WebAssembly for browser and edge environments.

What RustPython Does

  • Interprets Python 3 code with a bytecode compiler and virtual machine written in Rust
  • Compiles to WebAssembly so Python can run in browsers without server-side processing
  • Embeds into Rust applications as a scripting engine via a clean Rust API
  • Implements the Python standard library progressively, covering core modules like os, json, and re
  • Passes a growing portion of the CPython test suite to ensure compatibility

Architecture Overview

RustPython uses a multi-phase pipeline: a parser converts Python source into an AST, a compiler transforms the AST into bytecode, and a stack-based virtual machine executes it. The VM manages Python objects through Rust's ownership model, avoiding a global interpreter lock. Each Python object is a Rust struct implementing a PyValue trait, and the garbage collector leverages Rust's reference counting with cycle detection.

Self-Hosting & Configuration

  • Build from source with cargo build --release or install via cargo install
  • Use --target wasm32-wasi for WebAssembly builds
  • Embed by adding rustpython-vm as a Cargo dependency in your Rust project
  • Configure via standard Python mechanisms (PYTHONPATH, site-packages)
  • No external runtime dependencies; single static binary output

Key Features

  • Memory-safe Python execution without a GIL, enabling true parallelism potential
  • WebAssembly compilation for running Python in browsers and serverless environments
  • Clean embedding API for adding Python scripting to Rust applications
  • No C dependencies in the core interpreter, simplifying cross-compilation
  • Active development tracking CPython 3.12+ compatibility

Comparison with Similar Tools

  • CPython — the reference implementation with full ecosystem support; RustPython trades completeness for safety and portability
  • PyPy — JIT-compiled Python for speed; RustPython focuses on embedding and WASM rather than raw performance
  • Pyodide — CPython compiled to WASM via Emscripten; RustPython is a native Rust rewrite rather than a port
  • MicroPython — targets microcontrollers with a minimal subset; RustPython aims for full Python 3 compatibility
  • GraalPython — runs on GraalVM/JVM; RustPython produces standalone native or WASM binaries

FAQ

Q: Can RustPython run my existing Python projects? A: It depends on the project's dependencies. Pure Python code generally works, but C extension modules (numpy, pandas) are not supported.

Q: Is RustPython faster than CPython? A: Not currently for most workloads. The focus is on correctness and portability rather than raw speed.

Q: Can I use pip with RustPython? A: Basic pip support exists, but packages with C extensions will not install. Pure Python packages work.

Q: What Python version does it target? A: RustPython targets Python 3.12+ syntax and semantics, with ongoing work to close compatibility gaps.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires