pytimebudget
Zero-effort performance regression detection for Python.
pytimebudget helps you detect when parts of your code get slower over time, not just slow once. It stores historical timing data and warns you when performance regresses, with almost no setup.
No configuration required.
Just import it and use it.
✨ Features
- 📉 Regression detection - compares current runtime to historical baseline
- 💾 SQLite backend - persistent, fast, reliable
- 📦 Per-project isolation - each project gets its own database automatically
- ⚡ Async support - works with
async with - 🧠 Safe by default – never crashes your code
- 🔕 Opt-out anytime via environment variable
📦 Installation
pip install pytimebudget
🚀 Quick Start
Basic usage
import pytimebudget
import time
pytimebudget("startup", max_ms=100)
time.sleep(0.08)
If this code becomes significantly slower over time, pytimebudget will warn you.
Context manager (recommended)
import pytimebudget
import time
with pytimebudget("db_query", max_ms=40):
time.sleep(0.05)
Async support
import pytimebudget
import asyncio
async def main():
async with pytimebudget("async_task", max_ms=50):
await asyncio.sleep(0.02)
asyncio.run(main())
🧠 How It Works
For each named timing:
- Execution time is measured
- The result is stored in a SQLite database
- A rolling baseline is calculated
- If the current run is significantly slower than the baseline, a warning is emitted
This allows you to catch gradual slowdowns that traditional profiling misses.
📁 Per-Project Isolation
Each project automatically gets its own database, based on the project root
(.git, pyproject.toml, or setup.py).
Databases are stored in:
~/.pytimebudget/
This prevents unrelated projects from polluting each other’s timing data.
⚠️ Warnings
When a regression is detected, you’ll see something like:
[pytimebudget] Performance regression detected
Name: db_query
Baseline: 32.14 ms
Current: 51.87 ms
Slowdown: 1.61x
You can choose whether this is printed or emitted as a Python warning.
🎯 When Should You Use This?
- Detect performance regressions in long-lived projects
- Monitor critical paths (startup, I/O, parsing, DB access)
- Catch slowdowns before users do
- Add lightweight performance checks without profiling overhead
This is not a profiler, but it’s a regression detector.
🧪 Stability & Safety
- Uses only the Python standard library
- All internal errors are swallowed
- Never interrupts your application
- Safe for production use
📄 License
MIT License
Metadata
Release files for pytimebudget 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytimebudget-0.1.1.tar.gz | 4.8 kB | Without provenance | Details for pytimebudget-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytimebudget-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pytimebudget-0.1.1-py3-none-any.whl |
Total release size: 10.7 kB
Release files / pytimebudget-0.1.1.tar.gz
| Download URL | pytimebudget-0.1.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5320da74572abb992438cfd645be3d95f57ee46c2b2794c6355b0495c3ca053d
|
|
BLAKE2b-256 checksum How to use checksums |
965d824a15b0dc5fb70ea39b34429992c7a6b79b0c281057a4823107fe8cf722
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / pytimebudget-0.1.1-py3-none-any.whl
| Download URL | pytimebudget-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f3bf809db12f5182de7d51c521cc3a3b6426107e09dfb1e08ecf9d40ffadad0
|
|
BLAKE2b-256 checksum How to use checksums |
d6f8ab5eaddbae12433fd6d367aa97348cb71316f85d43e45a623cea2c25c7cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for pytimebudget 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.