The definitive concise python profiler, with minimal dependency and a small footprint, it is feature-complete with a cli, a web UI and dedicated file-logging.
- requires Python 3.12 or later.
- Install the package with pip:
pip install pyopsy
- Import
profilerandsessionfrompyopsy. - Put
@pyopsy.profileron a function. - The decorator supports a function, a generator, an async function, and an async generator.
str()on a marked function returns wall time and memory as JSON.- Open one session with
pyopsy.session(). - The session opens a web page on
127.0.0.1. - Set
cli=Trueto draw a terminal screen. - Set
logto a file path to append JSONL snapshots.
check example.py for a more complete and hands-on tutorial, it is setup to give a sample use-case for 4 different types of functions:
- normal function
- normal generator
- async function
- async generator
It also has a usecase for line recording.


