Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 1.63 KB

File metadata and controls

56 lines (43 loc) · 1.63 KB

RustPython Development Guide and Tips

Code organization

  • parser/src: python lexing, parsing and ast
  • vm/src: python virtual machine
    • builtins.rs: Builtin functions
    • compile.rs: the python compiler from ast to bytecode
    • obj: python builtin types
  • 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 build
  • tests: integration test snippets

Code style

The code style used is the default rustfmt codestyle. Please format your code accordingly. We also use clippy to detect rust code issues.

Testing

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
$ pipenv install
$ pipenv run pytest -v

There also are some unit tests, you can run those with cargo:

$ cargo test --all

Profiling

To 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).