Skip to content
← Back to the 2026 landscape
Compare

rpytest vs pytest: faster runs, same tests

rpytest is a Rust-daemon-backed drop-in for pytest. The daemon keeps the Python interpreter warm between runs so you stop paying startup cost on every invocation.

Install
$ pip install rpytest
TL;DR

rpytest is a Rust-backed drop-in for pytest. Same API, faster hot paths. Install: pip install rpytest. Faster warm runs (warm interpreter + pre-loaded conftest).

rpytest vs pytest: the facts

rpytest

Faster warm runs (warm interpreter + pre-loaded conftest).

pytest

Cold interpreter + import overhead on every run.

rpytest

Same pytest API — fixtures, markers, plugins, parametrize.

pytest

Native pytest.

rpytest

Same test discovery and config.

pytest

Native.

rpytest

Zero code changes: `pip install rpytest` and prefix `rpytest` instead of `pytest`.

pytest

Native pytest.

rpytest

MIT licensed, prebuilt wheels, Python 3.9+.

pytest

MIT licensed.

What the daemon actually removes

Every pytest invocation pays a fixed cost before a single assertion runs: start CPython, import the interpreter's own modules, import your dependency tree, import conftest files, then walk the tree collecting tests. On a suite with a heavy dependency graph — a web framework, an ORM, a scientific stack — that fixed cost can rival the time spent running the tests themselves, and it is paid identically on every run.

rpytest keeps a Python process resident between invocations so the second run does not repeat the first run's imports. The tests still execute through upstream pytest; only the warm-up is different. This is why the improvement is reported on warm runs. A single cold run in a fresh container improves very little, because there is no warm state to reuse.

Migration, and how to undo it

There is no migration. Install the package and type rpytest where you would have typed pytest. Fixtures, markers, parametrised cases, plugins and conftest.py are untouched, because they are being executed by pytest as usual. Uninstalling removes the daemon and returns you to exactly the behaviour you had before.

In CI the calculation is different and worth doing separately. A fresh runner is cold by definition, so the local speedup does not transfer unless your CI reuses machines or caches state between jobs. Measure your own pipeline rather than assuming the local number carries over.

Where plain pytest is the right choice

A resident daemon is a process that holds memory between runs and occasionally needs restarting. On a small suite, or on a constrained machine, that trade is not obviously worth it. Plugins that reach deep into pytest internals or that assume a fresh interpreter per run are the most likely source of surprising behaviour, so check your plugin list against the current release notes first.

pytest itself also wins on every dimension that is not startup: it is the upstream project, it has the larger plugin ecosystem, and it is what every tutorial and CI template assumes. rpytest is a wrapper around it precisely so that you keep all of that. Related loops are covered on the developer tools page.

When to use rpytest

  • You have a pytest suite of 100+ tests and CI is the bottleneck.
  • You want a 2-10× win with zero code changes.
  • Your dependency tree is heavy enough that import and collection dominate a short test run.

When NOT to use rpytest

  • You have <50 tests and CI is fast enough.
  • Your CI runners are cold on every job and never reuse state, so there is no warm interpreter to benefit from.
  • You rely on plugins that assume a fresh interpreter per run.

Frequently asked questions

Will rpytest run my existing pytest tests unmodified?

Yes. rpytest uses pytest under the hood; the daemon only manages interpreter warm-up. All fixtures, markers, plugins, and parametrize work as normal.

Is rpytest a fork of pytest?

No — it is a wrapper that invokes pytest inside a warm Python interpreter. You keep upstream pytest compatibility.

What happens if the daemon dies mid-run?

The run fails the way a killed pytest process would, and the next invocation starts a fresh daemon. No test state is carried across runs by design, so a restart cannot silently change a result.

Does rpytest change test isolation?

No. Tests execute through pytest with its normal fixture scoping and teardown. The daemon caches interpreter and import state, not test state.

Related comparisons