Python compiler written in Rust that transpiles Python bytecode to LLVM IR for optimized native compilation.
The tool's goal is to speed up Python code by:
- Generating Python bytecode through CPython's .pycache files
- Parsing and mapping the bytecode structure in Rust
- Converting the bytecode to LLVM Intermediate Representation (IR)
- Using LLVM's powerful optimization passes to generate highly optimized native code
This approach leverages LLVM's mature optimization pipeline and cross-platform capabilities, allowing for efficient native code generation across different architectures.
- Python 3.10.2 (CPython implementation)
- LLVM 16.0.4
- Generation and decompilation of .pycache files based on the .py files
- Variable declaration
- Integer addition and subtraction
- Printing to console
- Mapping of all primitive and non-primitive types
- Mapping of all operations
- User-defined functions
- Python standard library mapping
- Imports and modules
- Comprehensive test suite
- Benchmarks
- Python bytecode explanation on example 1
- Python bytecode explanation on example 2
- Article on bytecode decompilation
- Opcodes
- Opcode Ids
- Code object bit flags
- Exception handling encoding
- Bytecode address-to-line encoding
- Python bytecode instructions
- https://github.com/python/cpython/blob/main/Python/marshal.c
- https://github.com/python/cpython/blob/main/Include/cpython/code.h
- Unicode character values lookup
- https://github.com/ThePrimeagen/ts-rust-zig-deez/blob/master/rust/src/lexer/lexer.rs#L175
- https://github.com/ThePrimeagen/ts-rust-zig-deez/blob/master/python/deez_py/tokens.py
- https://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html
- https://nowave.it/python-bytecode-analysis-1.html