Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .importlinter
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ ignore_imports =
; Grimp doesn't understand extension modules: it thinks grimp._rustgrimp
; is an object within grimp, rather than a module in its own right,
; so we ignore these imports here.
grimp.adaptors.caching -> grimp
grimp.application.graph -> grimp
grimp.adaptors.filesystem -> grimp
grimp.application.scanning -> grimp
grimp.application.usecases -> grimp
14 changes: 7 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Grimp builds a queryable graph of the imports within one or more Python packages. It's a
hybrid Python/Rust project: the public API and orchestration are in Python
(`src/grimp/`), and the import scanning and graph algorithms are implemented in Rust
(`src/grimp/`), and the graph building and graph algorithms are implemented in Rust
(`rust/`) as a PyO3 extension module (`grimp._rustgrimp`), built with maturin.

## Architecture
Expand All @@ -11,18 +11,18 @@ hybrid Python/Rust project: the public API and orchestration are in Python
(see `.importlinter`):

- `domain/` — core types (`valueobjects.py`, `analysis.py`), no dependencies on other layers.
- `application/` — use cases and ports (`usecases.py`, `graph.py`, `scanning.py`, `config.py`).
- `adaptors/` — implementations of application ports (filesystem, module/package finding,
caching, timing).
- `application/` — use cases and ports (`usecases.py`, `graph.py`, `config.py`).
- `adaptors/` — implementations of application ports (package finding).
- `main.py` — top-level entry point (`grimp.build_graph`), wires adaptors to use cases.
- `exceptions.py` — shared exceptions, importable from any layer.

Respect this layering: `domain` must not import from `application` or `adaptors`, etc. Run
`just lint-python` (which includes `lint-imports`) to check.

The Rust side (`rust/src/`) does the heavy lifting: import parsing (via `ruff`'s parser),
module/import scanning, and graph algorithms (`rust/src/graph/`: pathfinding, cycle
detection, hierarchy queries, etc.).
The Rust side (`rust/src/`) does the heavy lifting. `grimp.build_graph` calls into
`rust/src/graph_building.rs`, which finds the modules, reads and writes the cache, scans the
imports (parsed via `ruff`'s parser) and assembles the graph. It also implements the graph
algorithms (`rust/src/graph/`: pathfinding, cycle detection, hierarchy queries, etc.).

## Setup

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
=========

latest
------

* Speed up ``build_graph`` by building the graph in Rust. This includes finding the modules, reading
and writing the cache, and assembling the graph. The cache files are unchanged.

3.20 (2026-11-13)
-----------------

Expand Down
92 changes: 63 additions & 29 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ const_format = "0.2.34"
ruff_python_parser = { git = "https://github.com/astral-sh/ruff.git", tag = "0.15.20" }
ruff_python_ast = { git = "https://github.com/astral-sh/ruff.git", tag = "0.15.20" }
ruff_source_file = { git = "https://github.com/astral-sh/ruff.git", tag = "0.15.20" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.137"
serde_yaml = "0.9"
unindent = "0.2.4"
serde_json = { version = "1.0.137", features = ["float_roundtrip"] }
encoding_rs = "0.8.35"
blake2 = "0.10.6"
unicode-ident = "1.0.24"
pyo3 = "0.29.0"

[features]
Expand Down
Loading
Loading