A timer context manager measuring the clock wall time of the code block it contains. Version 0.3.3 is the latest, with no recent updates (last release in 2018). The library provides a simple context manager and decorator for timing code blocks, defaulting to wall-clock time. It supports alternative timers via Python's time module.
Install & Compatibility
Where this runs
tested against v0.3.3 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.028s · 19.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.5s · import 0.022s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Direct import of Timer from contexttimer
from contexttimer import Timer
Decorator function, same import style
from contexttimer import timer
Basic usage: measure wall time of a code block using a context manager.
from contexttimer import Timer
import time
with Timer() as t:
time.sleep(1)
print(f"Elapsed: {t.elapsed}")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.