bottlenecks
Finds bottlenecks in four places, and ranks them all in one report:
| Domain | What it finds | How |
|---|---|---|
code |
nested loops (O(n^k)), blocking I/O in loops, += string building, regex/sort in loops, high complexity, long functions |
static AST analysis |
runtime |
hot functions, call-overhead hotspots, recursion | stdlib cProfile |
pipeline |
critical path, choke points, join barriers (fan-in), serial chains, worker starvation, saturated queue stages | DAG and queueing math |
system |
CPU saturation, run queue/load, I/O wait, memory pressure, swapping, full disks | psutil (optional) or /proc |
Each finding is a Bottleneck with a domain, a kind, a location, a score from 0 to 1, a severity, a suggestion and raw metrics.
The core has no dependencies. To get richer system data, including top processes, install the psutil extra.
Install
pip install bottlenecks # core, stdlib only
pip install "bottlenecks[system]" # + psutil
CLI
bottlenecks code src/ --top 20 # static analysis
bottlenecks code src/ --fail-on high # CI gate (exit 1)
bottlenecks run script.py arg1 arg2 # profile a script
bottlenecks pstats out.prof # analyse a saved profile
bottlenecks pipeline pipeline.json -f markdown # DAG / stage analysis
bottlenecks system --interval 1 # host resources
bottlenecks scan . # code + system
Output formats: text (default), json, markdown. Use -o FILE to write the report to a file.
Pipeline spec
{
"workers": 4,
"tasks": [
{"name": "fetch", "duration": 2},
{"name": "build", "duration": 10, "deps": ["fetch"]},
{"name": "lint", "duration": 1, "deps": ["fetch"]},
{"name": "test", "duration": 5, "deps": ["build"]},
{"name": "publish", "duration": 1, "deps": ["test", "lint"]}
],
"arrival_rate": 2.5,
"stages": [
{"name": "parse", "service_time": 0.1},
{"name": "embed", "service_time": 1.0, "workers": 2},
{"name": "store", "service_time": 0.2}
]
}
Python API
from bottlenecks import analyze_code, profile, analyze_dag, analyze_system, render
report = analyze_code("src/")
report.merge(analyze_system())
print(render(report, "text", top=10))
with profile(threshold=0.02) as p:
expensive()
print(render(p.report))
print(analyze_dag(tasks).summary["pipeline"]["critical_path"])
License
Licensed under Apache-2.0.
Metadata
Release files for bottlenecks 0.1.0
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 |
|---|---|---|---|---|
| bottlenecks-0.1.0.tar.gz | 23.0 kB | Without provenance | Details for bottlenecks-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bottlenecks-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bottlenecks-0.1.0-py3-none-any.whl |
Total release size: 45.8 kB
Release files / bottlenecks-0.1.0.tar.gz
| Download URL | bottlenecks-0.1.0.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad40385e16033eeb497954dde82d7d07fbb55c3f561de30e76a7e2df2c02d660
|
|
BLAKE2b-256 checksum How to use checksums |
5a81f9e9cac894f24fd9644f9fa01d9ad4e97e9496456d3f0fad51f91d3a6651
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / bottlenecks-0.1.0-py3-none-any.whl
| Download URL | bottlenecks-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f59347a84325a2ab15eda495f2280e33ebfb6bebab02db610927b60240dfc6b3
|
|
BLAKE2b-256 checksum How to use checksums |
ce106604d8ba40c19e16c93ca88131a2abde8e09fcfc6cdf9e3d39fd49ce85d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Security for bottlenecks 0.1.0
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.