Skip to content

Replace pre-commit with prek for faster linting#143148

@juhannc

Description

@juhannc

Feature or enhancement

Proposal:

First, I hope this is the correct issue template. If not, please let me know, and I can resubmit the proposal using the proper template.

prek is a "reimagined version of pre-commit, [...] designed to be a faster, dependency-free and drop-in alternative".
It has already been adopted by major projects from Apache, FastAPI, and Django (see prek/Who is using prek?).

Running prek against the entire CPython codebase yields a speedup of almost 2.5x without a cache and 1.25x with a warm cache.

hyperfine --warmup 2 --runs 5 \ --prepare "prek cache clean""prek run --all-files" \ --prepare "pre-commit clean""pre-commit run --all-files" Benchmark 1: prek run --all-files Time (mean ± σ): 19.835 s ± 0.290 s [User: 50.857 s, System: 6.248 s] Range (min … max): 19.527 s … 20.201 s 5 runs Benchmark 2: pre-commit run --all-files Time (mean ± σ): 48.944 s ± 0.448 s [User: 76.063 s, System: 6.096 s] Range (min … max): 48.522 s … 49.681 s 5 runs Summary prek run --all-files ran 2.47 ± 0.04 times faster than pre-commit run --all-files
hyperfine --warmup 2 --runs 5 \ "prek run --all-files" \ "pre-commit run --all-files" Benchmark 1: prek run --all-files Time (mean ± σ): 6.763 s ± 0.124 s [User: 35.990 s, System: 2.134 s] Range (min … max): 6.589 s … 6.900 s 5 runs Benchmark 2: pre-commit run --all-files Time (mean ± σ): 8.537 s ± 0.048 s [User: 43.797 s, System: 1.903 s] Range (min … max): 8.484 s … 8.608 s 5 runs Summary prek run --all-files ran 1.26 ± 0.02 times faster than pre-commit run --all-files

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    infraCI, GitHub Actions, buildbots, Dependabot, etc.type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions