bytecode/src: python bytecode representation in rust structurescompiler/src: python compilation to bytecodeparser/src: python lexing, parsing and astLib: Carefully selected / copied files from CPython sourcecode. This is the python side of the standard library.vm/src: python virtual machinebuiltins.rs: Builtin functionscompile.rs: the python compiler from ast to bytecodeobj: python builtin typesstdlib: Standard library parts implemented in rust.
src: using the other subcrates to bring rustpython to life.docs: documentation (work in progress)py_code_object: CPython bytecode to rustpython bytecode converter (work in progress)wasm: Binary crate and resources for WebAssembly buildtests: integration test snippets
The code style used is the default rustfmt codestyle. Please format your code accordingly. We also use clippy to detect rust code issues.
To test rustpython, there is a collection of python snippets located in the
tests/snippets directory. To run those tests do the following:
$ cd tests
$ pytest -vThere also are some unit tests, you can run those with cargo:
$ cargo test --allTo profile rustpython, simply build in release mode with the flame-it feature.
This will generate a file flamescope.json, which you can then view at
https://speedscope.app.
$ cargo run --release --features flame-it script.py
$ cat flamescope.json
{<json>}You can also pass the --output-file option to choose which file to output to
(or stdout if you specify -), and the --output-format option to choose if
you want to output in the speedscope json format (default), text, or a raw html
viewer (currently broken).