artimers
A utility package for timing and managing timers by Alexander Rießbeck
The goal of this package is it to provide easy to use timers that can collect timing data across your project and make the collected times accessible.
$ python -m pip install artimers
Usage
from artimers import Timer
Basics
Timer can be used in multiple ways
Class
Timer can be used as a class
timer = Timer()
timer.start()
...
final_time = timer.stop()
Decorator
Timer can be used as a decorator
@(timer:=Timer())
def foo():
...
print(timer)
Context Manager
Timer can be used as a context manager
with Timer() as timer:
...
x = timer.time
Pretty print
Timer also has a custom __str__ method
timer = Timer()
timer.start()
sleep(0.2)
print(timer)
sleep(0.2)
timer.stop()
print(timer)
Timer (Running): 0.2004s
Timer (Stopped): 0.4007s
If the timer is named (Timer('Stopwatch 1')) the name will be used instead of Timer.
Printed decimals
The deciaml point used in the __str__ function can also be set (default is 4 and timing seems to be accurate up to 2)
timer = Timer(decimal=5)
print(timer)
Naming
Timer can be named and easily accessed later by using the same name again
Timer('Stopwatch 1')
Timer(name='Stopwatch 2')
Named timers always return the same instance and therefore keep their time and status (Running/Stopped).
Get timers
Timer can return a dict of all named timers
named_timers = Timer.get_timers()
Print results
The final time can be printed when exiting a decorator or context manager
@(Timer(print_result=True))
def foo():
...
with Timer(print_result=True):
...
Return results
The final time can also be return from a decorated function
@(Timer(return_result=True))
def foo():
...
time, _ = foo()
Metadata
Release files for artimers 1.0.1
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 | |
|---|---|---|---|---|
| artimers-1.0.1.tar.gz | 3.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| artimers-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / artimers-1.0.1.tar.gz
| Download URL | artimers-1.0.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
164622c04b43c8a3d37e344eafd1fc39d2092bd94b1e8eab559349b6b5bed1a3
|
|
BLAKE2b-256 checksum How to use checksums |
505b76590d76a947788747dfc84e1c1fddabb7c461b51588dff501d4a47fca96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / artimers-1.0.1-py3-none-any.whl
| Download URL | artimers-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
427f83dbfaeb987a8edaf32bec6bc7c957efa210b137a81fec46506be4a9174e
|
|
BLAKE2b-256 checksum How to use checksums |
0fe39d2e7f1a8669a831df57837182e5cab8fcd0c1c1f4427f01d1196280f10d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for artimers 1.0.1
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.