Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

step3-0.1.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

step3-0.1.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

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

Hashes for step3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 48f3d2ef20309c60bf79efc1dbfe042aa78b14272e1483b9d1ea29234d7e1fc3
MD5 4563ef7455fbb6d4b185a05c4cff71aa
BLAKE2b-256 c649aab416126bbe1f936a4180fecaf57ae43e6b02e8bb7826ee17de6a863e63

See more details on using hashes here.

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

Hashes for step3-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fde2174c06e11cd1988e1e557d3357e7bee981eaea656470b2ac5352f5195515
MD5 5e1979192036a45d0d4b05583dc57dd8
BLAKE2b-256 24ba7ae4410e739dc5e8a95f41ffc9c7abffd5f5f0dd0aeceaf3a62e75f22df8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page