deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (native)

Rust-based dead code finder Unref claims 20x speedup over vulture, scanning CPython in under a second

Unref, a new Rust tool built on Ruff's parser, finds unused Python code and claims a 20x speedup over vulture, scanning all of CPython in under a second.

Rust-based dead code finder Unref claims 20x speedup over vulture, scanning CPython in under a second

What launched

A new open-source tool called Unref reached the front page of Hacker News on November 18. According to the project's GitHub repository, published under the handle Apakottur, Unref is a Python dead code finder written in Rust and built on Ruff's parser. Its job is narrow and well defined: report classes, functions and other definitions in a codebase that nothing references.

The output follows familiar linter conventions. The repository's example shows a file path, line and column, followed by a rule name such as unused-class or unused-function and the identifier in question.

The speed claim

The project's central claim is performance. According to the repository, its own benchmark script measures Unref at roughly 20 times faster than vulture, a long-standing Python dead code finder, scanning the entire CPython codebase — version 3.15.0, about 2,300 files — in under a second.

These are self-reported figures from the project's own benchmark rather than an independent comparison, and the repository does not publish vulture's timings on the same hardware. Even so, a large gap is plausible: porting scanning workloads from Python to Rust has produced order-of-magnitude gains elsewhere in the toolchain, most famously with Ruff itself, which displaced slower Python linters largely on speed.

Accuracy and framework awareness

Dead code detection in a dynamic language is genuinely difficult. Names can be reached through string-based lookups, dynamic imports and framework magic, so any static tool risks false positives. Unref addresses one specific blind spot, according to its repository: names are matched per module, so a symbol named parse that is genuinely used in one file will not hide an identically named, genuinely unused parse function in another.

To reduce setup friction, the tool ships built-in rules for pytest, Pydantic, SQLAlchemy and other popular frameworks — precisely the kind of frameworks whose conventions, such as fixtures and declarative models, tend to confuse naive unused-code checks. The project says most codebases should need little or no configuration as a result, and it explicitly invites false-positive reports as issues, an acknowledgment that the problem is not fully solved.

Built to sit next to Ruff

Unref leans on Ruff's ecosystem rather than competing with it. The repository describes Ruff-style conventions, options and output formatting, ty-style rule codes, and configuration through pyproject.toml. The project also positions it as complementary: it targets the unused code that Ruff leaves out — cross-module dead code detection, which requires reasoning about what is referenced across an entire project, not just within a single file.

Integration options listed include running the tool via uvx, as a pre-commit or prek hook, and in GitHub Actions. The sample configuration pairs it alongside Ruff's own check and format hooks. The project appears young — that example pins version 0.2.0 — with documentation hosted on Read the Docs.

Why it matters

Dead code is a slow tax on a codebase: it obscures what a program actually does, inflates review surface and makes refactors riskier than they need to be. Cleanup is usually deferred because the tooling is slow, noisy, or both. If Unref's claims hold, whole-repository dead-code scans become cheap enough to run in CI on every change rather than as an occasional purge — the same shift in habits that fast formatters and linters enabled a few years ago.

There is also a broader signal here. By building on Ruff's parser rather than writing its own, Unref treats that parser as shared infrastructure for the Python ecosystem, letting new tools inherit industrial-grade performance without reimplementing a Python parser in Rust. For teams already standardised on Ruff and uv, Unref is positioned as a near-zero-friction addition to an existing workflow, and its arrival suggests the layer of fast, composable Python tooling around Ruff is still growing.

  • #python
  • #rust
  • #static-analysis
  • #developer-tools
  • #open-source

Related posts