timer-for-python 0.7.1__py3-none-any.whl → 0.7.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
timer/model/timer.py CHANGED
@@ -21,7 +21,71 @@ class Timer(TimerBase):
21
21
  cls._instance = super().__new__(cls)
22
22
  return cls._instance
23
23
 
24
- def __init__(self, thread: str | None = None, decimals: int = constant.decimals.DEFAULT) -> None:
24
+ def __init__(self, thread: str | None = None, decimals: int = 2) -> None:
25
+ """Main class to create a Timer instance. If not using the class with a `with` statement as [context manager](../user-guide/context-manager.md), remember that a `timer.start()` should always be followed by `timer.stop()` later in the code.
26
+
27
+ Args:
28
+ thread (str | None, optional): Option to start new thread.
29
+ decimals (int | None, optional): Option to define decimals for output. Minimum `0` (for no decimals) and maximum `9`. If `None`, default is `2` decimals. May be overruled in certain cases due to [humanised output](../user-guide/humanised-output.md).
30
+
31
+ Example:
32
+ Basic usage:
33
+
34
+ ```python linenums="1" hl_lines="3"
35
+ from timer import Timer
36
+
37
+ timer = Timer()
38
+ timer.start()
39
+
40
+ # Insert your code here
41
+
42
+ timer.stop()
43
+ ```
44
+
45
+ Or with a `with` statement as [context manager](../user-guide/context-manager.md):
46
+
47
+ ```python linenums="1" hl_lines="3"
48
+ from timer import Timer
49
+
50
+ with Timer():
51
+ # Insert your code here
52
+ ```
53
+
54
+ In both cases, the terminal output example is the same:
55
+
56
+ ```text title=""
57
+ Elapsed time: 12.34 seconds
58
+ ```
59
+
60
+ With custom thread name and decimals:
61
+
62
+ ```python linenums="1" hl_lines="3"
63
+ from timer import Timer
64
+
65
+ timer = Timer(thread="my_thread", decimals=5)
66
+ timer.start()
67
+
68
+ # Insert your code here
69
+
70
+ timer.stop(thread="my_thread")
71
+ ```
72
+
73
+ Or with a `with` statement as [context manager](../user-guide/context-manager.md):
74
+
75
+ ```python linenums="1" hl_lines="3"
76
+ from timer import Timer
77
+
78
+ with Timer(thread="my_thread", decimals=5):
79
+ # Insert your code here
80
+ ```
81
+
82
+ As before, the terminal will output the same result in both cases:
83
+
84
+ ```text title=""
85
+ Elapsed time: 0.12345 seconds for thread MY_THREAD
86
+ ```
87
+ """
88
+
25
89
  if not self._lock_init: # Ensure that initialisation of the lists only runs the first time.
26
90
  self.threads: list[ThreadItem] = []
27
91
  self.context_manager_threads: list[str] = []
timer/version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version_info__ = (0, 7, 1)
1
+ __version_info__ = (0, 7, 3)
2
2
  __version__ = ".".join(map(str, __version_info__))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: timer-for-python
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Timer for Python
5
5
  Home-page: https://jakob-bagterp.github.io/timer-for-python/
6
6
  Download-URL: https://pypi.org/project/timer-for-python/
@@ -15,27 +15,27 @@ Project-URL: API Reference, https://jakob-bagterp.github.io/timer-for-python/ref
15
15
  Project-URL: Source Code, https://github.com/jakob-bagterp/timer-for-python
16
16
  Project-URL: Release Notes, https://github.com/jakob-bagterp/timer-for-python/releases
17
17
  Keywords: python,timer
18
- Platform: UNKNOWN
19
18
  Classifier: Programming Language :: Python :: 3
20
19
  Classifier: Programming Language :: Python :: 3.10
21
20
  Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: License :: OSI Approved :: MIT License
23
23
  Classifier: Operating System :: OS Independent
24
24
  Requires-Python: >=3.10
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE.md
27
- Requires-Dist: colorist (==1.6.0)
27
+ Requires-Dist: colorist ==1.7.1
28
28
  Provides-Extra: testing
29
- Requires-Dist: coverage (==7.2.7) ; extra == 'testing'
30
- Requires-Dist: flake8 (==6.1.0) ; extra == 'testing'
31
- Requires-Dist: mypy (==1.4.1) ; extra == 'testing'
32
- Requires-Dist: numpy (==1.25.1) ; extra == 'testing'
33
- Requires-Dist: pytest (==7.4.0) ; extra == 'testing'
34
- Requires-Dist: pytest-cov (==4.1.0) ; extra == 'testing'
35
- Requires-Dist: tox (==4.6.4) ; extra == 'testing'
36
-
37
- [![Latest version](https://img.shields.io/static/v1?label=version&message=0.7.1&color=yellowgreen)](https://github.com/jakob-bagterp/timer-for-python/releases/latest)
38
- ![Python 3.10 | 3.11 or higher](https://img.shields.io/static/v1?label=python&message=3.10%20|%203.11%2B&color=blueviolet)
29
+ Requires-Dist: coverage ==7.4.4 ; extra == 'testing'
30
+ Requires-Dist: flake8 ==7.0.0 ; extra == 'testing'
31
+ Requires-Dist: mypy ==1.9.0 ; extra == 'testing'
32
+ Requires-Dist: numpy ==1.26.4 ; extra == 'testing'
33
+ Requires-Dist: pytest ==8.1.1 ; extra == 'testing'
34
+ Requires-Dist: pytest-cov ==5.0.0 ; extra == 'testing'
35
+ Requires-Dist: tox ==4.14.2 ; extra == 'testing'
36
+
37
+ [![Latest version](https://img.shields.io/static/v1?label=version&message=0.7.3&color=yellowgreen)](https://github.com/jakob-bagterp/timer-for-python/releases/latest)
38
+ [![Python 3.10 | 3.11 | 3.12+](https://img.shields.io/static/v1?label=python&message=3.10%20|%203.11%20|%203.12%2B&color=blueviolet)](https://www.python.org)
39
39
  [![MIT license](https://img.shields.io/static/v1?label=license&message=MIT&color=blue)](https://github.com/jakob-bagterp/timer-for-python/blob/master/LICENSE.md)
40
40
  [![Codecov](https://codecov.io/gh/jakob-bagterp/timer-for-python/branch/master/graph/badge.svg?token=P4IT8WQO0R)](https://codecov.io/gh/jakob-bagterp/timer-for-python)
41
41
  [![CodeQL](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/codeql.yml/badge.svg)](https://github.com/jakob-bagterp/timer-for-python/actions/workflows/codeql.yml)
@@ -156,5 +156,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
156
156
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
157
157
 
158
158
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
159
-
160
-
@@ -1,11 +1,6 @@
1
1
  timer/__init__.py,sha256=VP-n29fPZdottjrmQYnt4cYVH5Dq6Bx3CQ5-dlDPK9E,161
2
2
  timer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- timer/version.py,sha256=ZvLIpSfc3syZkqhsd4V1uVaJKxzP2tDYd-urkGfWq7Y,80
4
- timer/.pytest_cache/.gitignore,sha256=Ptcxtl0GFQwTji2tsL4Gl1UIiKa0frjEXsya26i46b0,37
5
- timer/.pytest_cache/CACHEDIR.TAG,sha256=N9yI75oKvt2-gQU6bdj9-xOvthMEXqHrSlyBWnSjveQ,191
6
- timer/.pytest_cache/README.md,sha256=c_1vzN2ALEGaay2YPWwxc7fal1WKxLWJ7ewt_kQ9ua0,302
7
- timer/.pytest_cache/v/cache/nodeids,sha256=T1PNoYwrqgwDVLtfmj7L5e0Sq02OEbqHPC8RFhICuUU,2
8
- timer/.pytest_cache/v/cache/stepwise,sha256=T1PNoYwrqgwDVLtfmj7L5e0Sq02OEbqHPC8RFhICuUU,2
3
+ timer/version.py,sha256=6u_k2jaEpuqNZzq4OATsc3rTamGM_dgzAfzvskmRzTs,80
9
4
  timer/constant/__init__.py,sha256=0e0W-lRc5xtJ9LSsEyq4o6zKckaRweAvrntmFE1gisE,67
10
5
  timer/constant/decimals.py,sha256=9SKe-IbFIbXY-Mps6bSYBqaWuxLiRlsa3rNmT_oDbiM,53
11
6
  timer/constant/various.py,sha256=v_UX49eVff3JnXs_VgS0luKkCc3iIH_EUalPxNt8-YQ,117
@@ -22,15 +17,10 @@ timer/model/__init__.py,sha256=m-K3jgLBqKUwBNJByKeLiGQCzCVZC07N12_SmkbGxyg,145
22
17
  timer/model/elapsed_time_fractions.py,sha256=UXfABMQ14kgsEHjQmef2PKMgtdqKF9zPyrmA9_TQHrg,282
23
18
  timer/model/thread_item.py,sha256=4c6cOAvTuy1Yi30oG46nHM84Bgu3c5aj7vTKjPyVQE8,212
24
19
  timer/model/time_fractions.py,sha256=yweResJFS7NutBoLWZYKC1f7GIemwWVIiEc04xsxOno,1298
25
- timer/model/timer.py,sha256=HSsGpRquyqYL-kPSZbEFNJ-UzUnBorXJOmieV0KFpuY,4950
20
+ timer/model/timer.py,sha256=2_zTd3IzSnQ_hKDSazJdNlTVAbmm1p7fhIrpJHx_uw4,7017
26
21
  timer/model/timer_base.py,sha256=SjDT1qu3wR9c89VmIpScXEDWOI0My5mbboLD6A7jir0,557
27
- timer/model/.pytest_cache/.gitignore,sha256=Ptcxtl0GFQwTji2tsL4Gl1UIiKa0frjEXsya26i46b0,37
28
- timer/model/.pytest_cache/CACHEDIR.TAG,sha256=N9yI75oKvt2-gQU6bdj9-xOvthMEXqHrSlyBWnSjveQ,191
29
- timer/model/.pytest_cache/README.md,sha256=c_1vzN2ALEGaay2YPWwxc7fal1WKxLWJ7ewt_kQ9ua0,302
30
- timer/model/.pytest_cache/v/cache/nodeids,sha256=T1PNoYwrqgwDVLtfmj7L5e0Sq02OEbqHPC8RFhICuUU,2
31
- timer/model/.pytest_cache/v/cache/stepwise,sha256=T1PNoYwrqgwDVLtfmj7L5e0Sq02OEbqHPC8RFhICuUU,2
32
- timer_for_python-0.7.1.dist-info/LICENSE.md,sha256=bV6mZhoYf6kHYGgsG3ArjpF_tjOweaI7QZKRvmzkUMI,1085
33
- timer_for_python-0.7.1.dist-info/METADATA,sha256=LxeewmFK23jGTHU30BC1cfUVM0iipDqiNyLqSApDLTY,6802
34
- timer_for_python-0.7.1.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
35
- timer_for_python-0.7.1.dist-info/top_level.txt,sha256=mbqaJ4u4Wh38RQxq5PFpTOu6h1EcSHjwI2bqdDYCRAI,6
36
- timer_for_python-0.7.1.dist-info/RECORD,,
22
+ timer_for_python-0.7.3.dist-info/LICENSE.md,sha256=bV6mZhoYf6kHYGgsG3ArjpF_tjOweaI7QZKRvmzkUMI,1085
23
+ timer_for_python-0.7.3.dist-info/METADATA,sha256=Mc9w568DOzr4DUfBmNJSqtFmLqyVsrKk5Ldd2mvODoA,6853
24
+ timer_for_python-0.7.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
25
+ timer_for_python-0.7.3.dist-info/top_level.txt,sha256=mbqaJ4u4Wh38RQxq5PFpTOu6h1EcSHjwI2bqdDYCRAI,6
26
+ timer_for_python-0.7.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,2 +0,0 @@
1
- # Created by pytest automatically.
2
- *
@@ -1,4 +0,0 @@
1
- Signature: 8a477f597d28d172789f06886806bc55
2
- # This file is a cache directory tag created by pytest.
3
- # For information about cache directory tags, see:
4
- # https://bford.info/cachedir/spec.html
@@ -1,8 +0,0 @@
1
- # pytest cache directory #
2
-
3
- This directory contains data from the pytest's cache plugin,
4
- which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
-
6
- **Do not** commit this to version control.
7
-
8
- See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
@@ -1 +0,0 @@
1
- []
@@ -1 +0,0 @@
1
- []
@@ -1,2 +0,0 @@
1
- # Created by pytest automatically.
2
- *
@@ -1,4 +0,0 @@
1
- Signature: 8a477f597d28d172789f06886806bc55
2
- # This file is a cache directory tag created by pytest.
3
- # For information about cache directory tags, see:
4
- # https://bford.info/cachedir/spec.html
@@ -1,8 +0,0 @@
1
- # pytest cache directory #
2
-
3
- This directory contains data from the pytest's cache plugin,
4
- which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
-
6
- **Do not** commit this to version control.
7
-
8
- See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
@@ -1 +0,0 @@
1
- []
@@ -1 +0,0 @@
1
- []