Image

Hugo van Kemenade: Ready prek go!

I’ve been usingprekrecently as a drop-in replacement forpre-commit.

It uses uv for managing Python virtual environments and dependencies, is rewritten in Rust (because of course) and uses the same.pre-commit-config.yamlas pre-commit.

Its homepage says it’s not yet production ready, butseveral projects like Apache Airflow and PDMare already using it. I’ve been using it for a while and reporting issues as I find them; the maintainer is quick with fixes and releases. All the hooks I need are now supported.

Getting started#

First install using one of themany methods, then:

Benchmarks#

prek is noticeably quicker at installing hooks.

  • ⚡ About10x fasterthan pre-commit and uses only a third of disk space.

This 10x is a comparison of installing hooks using the excellenthyperfinebenchmarking tool.

Here’s my own comparison.

In the first test, I initially ranpre-commit cleanorprek cleanto clear their caches. I then ran each tool withrun --all-filesin serial on the 126 repos I have cloned right now, 84 of which have a.pre-commit-config.yamlfile. Each then downloads and installs the hooks when needed, then runs the lint tools.

Second, because running the lint tools should be independent and constant time for both tools, the next test raninstall-hooksinstead ofrun --all files.

To get an idea of the amount of work for these two tests, pre-commit reported initialising environments 217 times.

Finally, let’s run hyperfine on thePillow config, which installs hooks from 14 repos:

Results#

The hyperfine results:

Benchmark 1: prek install-hooks Time (mean ± σ): 5.539 s ± 0.176 s [User: 8.973 s, System: 5.692 s] Range (min … max): 5.231 s … 5.834 s 10 runs Benchmark 2: pre-commit install-hooks Time (mean ± σ): 39.841 s ± 2.017 s [User: 19.760 s, System: 8.203 s] Range (min … max): 36.930 s … 43.976 s 10 runs Summary prek install-hooks ran 7.19 ± 0.43 times faster than pre-commit install-hooks

Give it a try and give it a!


Header photo:AH-1G Aircraft Maintenance Test Flight Handbook and handwritten checklist for helicoptersin theSan Diego Air and Space Museum Archive, withno known copyright restrictions.

https://hugovk.dev/blog/2025/ready-prek-go/