cleantimer
Track progress of long-running scripts, without cluttering your code with log statements.
cleantimer is a minimal wrapper around a couple of my favorite packages for timing scripts - contexttimer and tqdm. It merges their most useful features in a clean API based simply on the way I've found I like to use them. Hopefully you find it simply useful. 😊
Installation
pip install cleantimer
Import:
from cleantimer import CTimer
Use cases
A basic timer with a message for what you're timing:
with CTimer("Waking up"):
sleep(4)
Waking up (3:22PM)...done. (4.0s)
Print with varying precision:
with CTimer("Waking up", 3):
sleep(4.123456)
Waking up (3:22PM)...done. (4.123s)
Sub-timers
with CTimer("Making breakfast") as timer:
sleep(2)
with timer.child("cooking eggs") as eggtimer:
sleep(3)
with timer.child("pouring juice"):
sleep(1)
Making breakfast (3:22PM)...
cooking eggs (3:22PM)...done. (3.0s)
pouring juice (3:23PM)...done. (1.0s)
done. (6.0s)
Progress meter on a Pandas apply
df = pd.DataFrame({"A": list(range(10000))})
def times2(row): return row["A"] * 2
with CTimer("Computing doubles") as timer:
df["2A"] = timer.progress_apply(df, times2)
Computing doubles (3:22PM)...
: 100% ██████████████████████████ 10000/10000 [00:07<00:00, 135869it/s]
done. (7.4s)
Segmented progress meter
df = pd.DataFrame({"A": list(range(10000)), "type": [1]*5000 + [2]*5000})
def times2(row): return row["A"] * 2
with CTimer("Computing doubles") as timer:
df["2A"] = timer.progress_apply(df, times2, split_col="type", message="part {}")
Computing doubles (3:22PM)...
part 1: 100% ██████████████████████████ 5000/5000 [00:07<00:00, 135869it/s]
part 2: 100% ██████████████████████████ 5000/5000 [00:07<00:00, 122854it/s]
done. (8.2s)
Metadata
Release files for cleantimer 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cleantimer-0.0.2.tar.gz | 17.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cleantimer-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.3 kB
Release files / cleantimer-0.0.2.tar.gz
| Download URL | cleantimer-0.0.2.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91e0a8e1708a2ef19eae3085b3dfe9d1831309648f07d783bc9aaedb37072f3a
|
|
BLAKE2b-256 checksum How to use checksums |
f1b71211ff034d28971b8c7365a5fafe78d83232e653888a192620df55e7fdb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / cleantimer-0.0.2-py3-none-any.whl
| Download URL | cleantimer-0.0.2-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d692774600faff7b1eac56eb77ed722d288651c05ac1afc4d0b6b6aabdf9848d
|
|
BLAKE2b-256 checksum How to use checksums |
27aad3c9d95f48303f951b5210b3042dcb6d6fffd5270867c2e02c0a5f9b68fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for cleantimer 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.