https://github.com/art049/pydot-rs
A simple DOT parser Rust native module for Python
https://github.com/art049/pydot-rs
Last synced: 2 months ago
JSON representation
A simple DOT parser Rust native module for Python
- Host: GitHub
- URL: https://github.com/art049/pydot-rs
- Owner: art049
- License: mit
- Created: 2023-04-30T21:37:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-22T14:44:44.000Z (over 1 year ago)
- Last Synced: 2025-02-13T04:22:09.497Z (4 months ago)
- Language: Python
- Homepage:
- Size: 285 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pydot-rs
A simple DOT parser built for my talk Building native Rust modules for Python([video](https://www.youtube.com/watch?v=r2wCF5DjNJ4), [slides](https://slides.com/art049/native-rust-modules-for-python)).
This contains two implementations of the same parser, one in pure Python and one as a Rust module bound to Python using [PyO3](https://github.com/PyO3/pyo3) and [rustimport](https://github.com/mityax/rustimport).
## Running the project
### Pre-requisites:
- [Poetry](https://python-poetry.org/docs/#installation)
- A rust toolchain: It's recommended to use [rustup](https://rustup.rs/) to install it### Dependencies
```bash
poetry install
```### Running the tests
```bash
poetry run pytest
```## Performance change
[The GitHub Action workflow](.github/workflows/codspeed.yml) runs benchmarks on every push to the main branch and also on every pull request using [CodSpeed](https://codspeed.io/).
[This PR](https://github.com/art049/pydot-rs/pull/2) changes the default parsing implementations from the pure Python one to the Rust one and shows the performance change between the two. More performance details can be seen directly on the [CodSpeed Dashboard](https://codspeed.io/art049/pydot-rs/branches/switch-to-rust-implementation)
[](https://codspeed.io/art049/pydot-rs/branches/switch-to-rust-implementation)
_(Note that the performance gain is a bit lesser than in the talk since the number of edges in the graph has been reduced to make the tests run faster)_## Repository structure
```
├── pydot_rs <- the main python module
│ ├── **init**.py <- reexports from both implementations
│ ├── dot_python <- the pure python implementation
│ └── dot_rust <- the rust native module
├── samples <- some DOT graph samples
└── tests <- tests and benchmarks```