A small, focused Python profiler
Project description
step3: profit
A small, focused Python profiler built on sys.monitoring (Python 3.12+).
Installation
uv tool install step3 # recommended
Or run without installing:
uvx --from step3 profit
Or with pip: pip install step3
Usage
profit run — profile a script
profit run script.py
Focus on specific functions:
profit run script.py -p mymod:func1 -p mymod:func2
Compare two functions side by side:
profit run script.py -b mymod:func_old -p mymod:func_new
Run a module:
profit run -m mypackage.module
Pass arguments to the script after --:
profit run script.py -- --script-arg value
Options
| Flag | Description |
|---|---|
-p TARGET |
Function to show (repeatable) |
-b TARGET |
Baseline function for comparison |
-m MODULE |
Run a module as a script |
--sort |
Sort by cumulative, tottime, or calls (default: cumulative) |
--limit N |
Max functions to show (default: 20) |
Targets use importable names: mymod:MyClass.method or mymod.func.
profit timeit — profile a statement in a loop
profit timeit 'sum(range(1000))'
With setup code:
profit timeit 'f()' --setup 'from mymod import f'
Focus on specific functions:
profit timeit 'f()' --setup 'from mymod import f' -p mymod:f
Options
| Flag | Description |
|---|---|
--setup STMT |
Setup statement (default: pass) |
-n N |
Number of executions (default: auto) |
-p TARGET |
Function to show (repeatable) |
-b TARGET |
Baseline function for comparison |
--sort |
Sort by cumulative, tottime, or calls (default: cumulative) |
--limit N |
Max functions to show (default: 20) |
Global options
| Flag | Description |
|---|---|
--no-color |
Disable colored output |
Python API
Context manager — profile a block of code:
from step3 import profit
with profit as p:
do_work()
p.print_stats()
Decorator — profile a specific function:
from step3 import profit
@profit
def my_func():
...
my_func()
profit.print_stats()
Requirements
- Python 3.12+
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file step3-0.1.0.tar.gz.
File metadata
- Download URL: step3-0.1.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48f3d2ef20309c60bf79efc1dbfe042aa78b14272e1483b9d1ea29234d7e1fc3
|
|
| MD5 |
4563ef7455fbb6d4b185a05c4cff71aa
|
|
| BLAKE2b-256 |
c649aab416126bbe1f936a4180fecaf57ae43e6b02e8bb7826ee17de6a863e63
|
File details
Details for the file step3-0.1.0-py3-none-any.whl.
File metadata
- Download URL: step3-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fde2174c06e11cd1988e1e557d3357e7bee981eaea656470b2ac5352f5195515
|
|
| MD5 |
5e1979192036a45d0d4b05583dc57dd8
|
|
| BLAKE2b-256 |
24ba7ae4410e739dc5e8a95f41ffc9c7abffd5f5f0dd0aeceaf3a62e75f22df8
|