brilliant-learn-python 0.1.3__tar.gz → 0.1.5__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: brilliant-learn-python
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: Add your description here
5
5
  Author: Oliver Tautz
6
6
  Author-email: Oliver Tautz <oliver_tautz@yahoo.de>
@@ -4,7 +4,7 @@ description = "Add your description here"
4
4
  name = "brilliant-learn-python"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.14"
7
- version = "0.1.3"
7
+ version = "0.1.5"
8
8
 
9
9
  [[project.authors]]
10
10
  name = "Oliver Tautz"
@@ -7,7 +7,7 @@ description = "Add your description here"
7
7
  name = "brilliant-learn-python"
8
8
  readme = "README.md"
9
9
  requires-python = ">=3.14"
10
- version = "0.1.3"
10
+ version = "0.1.5"
11
11
 
12
12
  [build-system]
13
13
  build-backend = "uv_build"
@@ -0,0 +1,26 @@
1
+ """Context manager for measuring execution time."""
2
+
3
+ import time
4
+ from contextlib import AbstractContextManager
5
+ from types import TracebackType
6
+ from typing import Self
7
+
8
+
9
+ class Timer(AbstractContextManager["Timer"]):
10
+ """Measure execution time."""
11
+
12
+ def __init__(self) -> None:
13
+ self.start = 0.0
14
+ self.elapsed = 0.0
15
+
16
+ def __enter__(self) -> Self:
17
+ self.start = time.perf_counter()
18
+ return self
19
+
20
+ def __exit__(
21
+ self,
22
+ exc_type: type[BaseException] | None,
23
+ exc_value: BaseException | None,
24
+ traceback: TracebackType | None,
25
+ ) -> None:
26
+ self.elapsed = time.perf_counter() - self.start