Registry / observability / profilehooks

profilehooks

JSON →
library1.13.0pypypi✓ verified 86d ago

A collection of decorators for profiling, timing, and tracing individual functions. Current version 1.13.0, requires Python >=3.7. Release cadence is intermittent, with minor updates.

pip install profilehooks
INSTALL
IMPORT
SIG · PROFILEHOOKS
P
profilehooks
observabilitypythonv1.13.0
Install
1.7s avg
Import
100ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.13.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.108s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.092s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

timecall
from profilehooks import timecall
profile
from profilehooks import profile
coverage
from profilehooks import coverage

Basic usage of @timecall and @profile decorators.

from profilehooks import timecall, profile def slow_function(n): total = 0 for i in range(n): total += i ** 2 return total # Time a single call @timecall def timed_slow(n): return slow_function(n) timed_slow(100000) # Profile a function @profile def profiled_slow(n): return slow_function(n) profiled_slow(100000)
Debug
Known issues
gotchaWhen using @timecall, the decorator prints timing output to stderr by default. If you capture stdout only, you'll miss the output.
fix
Import sys and direct output: @timecall(stdout=sys.stdout) or use logging.
affects: all
deprecatedThe 'cover' decorator is deprecated. Use 'coverage' instead.
fix
Replace @cover with @coverage.
affects: >=1.11.0
gotchaThe @profile decorator does NOT work with async functions. Using it on an async def will raise an error or produce no profiling output.
fix
Do not use @profile on async functions; use @timecall or manual profiling.
affects: all
Errors
Common errors & fixes
AttributeError: module 'profilehooks' has no attribute 'cover'
The 'cover' function was renamed to 'coverage' in version 1.11.0.
fix
Use 'from profilehooks import coverage' instead of 'cover'.
TypeError: 'NoneType' object is not callable when using @profile on async function
The @profile decorator does not support async functions.
fix
Remove @profile from async functions, or use @timecall with appropriate handling.
Upgrade
Version history
1.13.0latest on PyPI · released Oct 9, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
2
Amazon
1
Resources
profilehooks — pip install profilehooks · libregistry