A starter Python interpreter written in Rust. This is intended as a learning exercise which could evetually become a drop-in replacement for python, but it is not there yet. Think LLVM but exponentially less useful.
memphis contains a few execution modes, each for learning about a different aspect of interpreter/compiler development:
- treewalk (default): farthest along in development.
- bytecode VM: foundation complete, but missing many Python features.
See SUPPORTED.md for details on specific features.
- Minimal dependencies. Uses zero dependencies by default. This means you can run Python code which does not call the stdlib (limiting, I know) through the treewalk interpreter or bytecode VM using no third-party Rust code. I find this kinda neat and worth preserving. The following crates are used behind feature flags for certain interfaces.
wasm-bindgen/serde: Only needed for WASM interface.crossterm: Only needed for Terminal REPL support.
- No shortcuts. This is a learning exercise, so try to do things the "right" way, even if it takes a few tries.
- Functionality first, readability second, performance third. Don't do anything obviously wasteful, but there are dozens of non-optimal performance decisions in here in the name of a simple implementation.
Installation requires a 2021 edition of rustc (version 1.56.0 or higher).
git clone https://github.com/fromscratchcode/memphis
cd memphis
cargo install --path .Use memphis as if it were python/python3 and provide the path to a Python module.
memphis examples/test.py
# or run using the bytecode VM (WARNING: many features currently unsupported)
MEMPHIS_ENGINE=bytecode_vm memphis examples/test.pyOr launch the REPL (requires a build with the repl feature flag).
> memphis
memphis 0.1.0 REPL (engine: treewalk) (Type 'exit()' to quit)
>>>See DEVELOPING.md for instructions on local development.
Memphis is a personal lab where I explore how Python works under the hood.
The code is open to explore and learn from, but I’m not actively seeking external contributions.
If you’re building something similar or just want to chat, feel free to reach out on Discord.
Important Notice: This project is currently in active development and is still considered experimental. As such, it is not recommended for use in production environments.
This project is licensed under the MIT License. See LICENSE for details.
