Registry / observability / contexttimer

contexttimer

JSON →
library0.3.3pypypi✓ verified 35d ago

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.

observabilitytesting
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.028s · 19.2MB
glibc
py 3.103.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}")
Debug
Known footguns
gotchaThe default timer is time.perf_counter (Python 3) or time.clock (Python 2). On Python 3.7+, time.clock is removed, but the library handles it. Still, avoid relying on time.clock.
deprecatedThe library is no longer actively maintained (last release 2018). It may have issues with newer Python versions (3.10+).
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.

Agent activity
16 hits · last 30 days
gptbot
4
ahrefsbot
4
claudebot
3
script
1
bytedance
1
Resources