DEV Community

Deepanshu
Deepanshu

Posted on

Stop Guessing How Fast Your Python Code Is

Every Python developer has been there. Your app is slow. You add a few print(time.time()) calls, squint at the output, and somehow convince yourself you've done profiling. Then you do it again next week.
There had to be a better way — one that takes literally one line of code, lives inside your process, and gives you real numbers. So I built pytrackio.
The whole API, in 30 seconds
bashpip install pytrackio
pythonfrom pytrackio import track, report

@track
def process_order(order_id):
# your existing code — untouched
pass

process_order(123)
process_order(456)
report()

Output:

pytrackio · Performance Report uptime: 2.31s

Name Calls Avg Min Max p95 p99

process_order 2 118ms 98ms 138ms 136ms 138ms

No boilerplate. No teardown. Just add @track.
What makes it different
Zero dependencies. Pure Python stdlib. Nothing to audit, nothing to break.
In-process. No sidecar, no agent, no network call. Runs right where your code runs.
Async-ready. Works on coroutines out of the box. @track detects async automatically.
Thread-safe. Safe for concurrent workloads. No extra configuration needed.
Beyond the decorator
Manual timing with timer():
pythonfrom pytrackio import timer

with timer("stripe_api_call"):
result = stripe.charge(amount)
Event counting with counter():
pythonfrom pytrackio import counter

counter("payments_processed").increment()
counter("errors").increment()
Export your data:
pythonfrom pytrackio import export_json, export_csv

export_json("metrics.json") # for log pipelines
export_csv("metrics.csv") # for spreadsheets
Come help build it
pytrackio is open source and actively looking for contributors. Every issue has a full description, clear acceptance criteria, and zero gatekeeping. First PR welcome.

Django / Flask middleware — Good first issue
JSON Lines structured logging — Good first issue
Auto-reset with reset_after=N — Good first issue
Class method support for @track — Intermediate
Histogram bucketing — Intermediate

🔗 GitHub: https://github.com/danshu3007-lang/pytrackio
🔗 PyPI: https://pypi.org/project/pytrackio
🔗 Issues: https://github.com/danshu3007-lang/pytrackio/issues
Questions or ideas? Drop a comment below — I read everything.

Top comments (0)