Registry / observability / stopwatch-py

stopwatch-py

JSON →
library2.0.1pypypi✓ verified 85d ago

stopwatch-py is a lightweight Python library providing a simple stopwatch functionality to measure elapsed time. It is currently at version 2.0.1 and has a low release cadence, primarily focusing on minor improvements and maintenance.

pip install stopwatch-py
INSTALL
IMPORT
SIG · STOPWATCH-PY
S
stopwatch-py
observabilitypythonv2.0.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.1 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

Stopwatch
from stopwatch import Stopwatch
from stopwatch.stopwatch import Stopwatch
As of v2.0.1, the library was refactored into a single-file module, removing the submodule structure.

Initializes a stopwatch, measures time, stops and resumes, then resets it.

from stopwatch import Stopwatch import time s = Stopwatch() # Starts automatically on creation print(f"Stopwatch started. Elapsed: {s.duration:.2f}s") time.sleep(1.5) print(f"After 1.5s, Elapsed: {s.duration:.2f}s") s.stop() print(f"Stopwatch stopped. Elapsed: {s.duration:.2f}s") time.sleep(0.5) print(f"After 0.5s while stopped, Elapsed: {s.duration:.2f}s (should be same)") s.start() # Resume time.sleep(0.75) print(f"After resuming for 0.75s, Total Elapsed: {s.duration:.2f}s") s.reset() # Reset to 0 and stop print(f"Stopwatch reset. Elapsed: {s.duration:.2f}s")
Debug
Known issues
breakingMethods `start()`, `stop()`, `reset()`, `restart()` no longer return `self`. This change in v2.0.0 breaks method chaining.
fix
Separate method calls. Instead of `s.stop().duration`, use `s.stop(); print(s.duration)`.
affects: >=2.0.0
breakingThe minimum required Python version increased from Python 3.0 to Python 3.5 due to the introduction of type hints in v2.0.0.
fix
Ensure your Python environment is 3.5 or newer. If you must use an older Python version, pin `stopwatch-py<2.0.0`.
affects: >=2.0.0
gotchaThe internal `__github__` constant was removed in v2.0.1. While this was not intended to break user code, any specific reliance on this internal constant will now fail.
fix
Remove any references to `stopwatch.__github__` from your code.
affects: >=2.0.1
Errors
Common errors & fixes
AttributeError: 'NoneType' object has no attribute 'duration'
Attempting to chain methods like `s.stop().duration` after upgrading to v2.0.0+. Methods `start()`, `stop()`, `reset()`, `restart()` no longer return `self`.
fix
Separate the method calls: `s.stop(); print(s.duration)`.
SyntaxError: invalid syntax (often pointing to type hints) or ModuleNotFoundError: No module named 'stopwatch'
Running `stopwatch-py` v2.0.0+ on Python versions older than 3.5, which do not support the introduced type hints.
fix
Upgrade your Python interpreter to version 3.5 or newer, or downgrade the library to `pip install stopwatch-py==1.x`.
ImportError: cannot import name 'Stopwatch' from 'stopwatch.stopwatch' (.../stopwatch/stopwatch.py)
Attempting to import `Stopwatch` from a submodule path (`stopwatch.stopwatch`) which was used in earlier versions. As of v2.0.1, it's a single-file module.
fix
Update your import statement to `from stopwatch import Stopwatch`.
Upgrade
Version history
2.0.1latest on PyPI · released Sep 4, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
stopwatch-py — pip install stopwatch-py · libregistry