brilliant-learn-python 0.1.7__tar.gz → 0.1.9__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.
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/PKG-INFO +1 -1
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/pyproject.toml +1 -1
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/pyproject.toml.orig +1 -1
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/src/brilliant_learn_python/decorators/timer.py +4 -2
- brilliant_learn_python-0.1.9/src/brilliant_learn_python/iterators/countdown.py +15 -0
- brilliant_learn_python-0.1.9/src/brilliant_learn_python/py.typed +0 -0
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/README.md +0 -0
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/src/brilliant_learn_python/__init__.py +0 -0
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/src/brilliant_learn_python/context_managers/__init__.py +0 -0
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/src/brilliant_learn_python/context_managers/timer.py +0 -0
- {brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/src/brilliant_learn_python/decorators/__init__.py +0 -0
- /brilliant_learn_python-0.1.7/src/brilliant_learn_python/py.typed → /brilliant_learn_python-0.1.9/src/brilliant_learn_python/iterators/__init__.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Decorator for measuring function execution time."""
|
|
2
2
|
|
|
3
3
|
from collections.abc import Callable
|
|
4
|
+
from functools import wraps
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
6
7
|
from brilliant_learn_python.context_managers.timer import Timer
|
|
@@ -9,12 +10,13 @@ from brilliant_learn_python.context_managers.timer import Timer
|
|
|
9
10
|
def timer(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
10
11
|
"""Measure the execution time of a function."""
|
|
11
12
|
|
|
13
|
+
@wraps(func)
|
|
12
14
|
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
13
15
|
"""Execute the wrapped function and measure its duration."""
|
|
14
16
|
|
|
15
|
-
with Timer() as
|
|
17
|
+
with Timer() as t:
|
|
16
18
|
result = func(*args, **kwargs)
|
|
17
|
-
print(f"func {func.__name__} ran for {
|
|
19
|
+
print(f"func {func.__name__} ran for {t.get_elapsed()}")
|
|
18
20
|
|
|
19
21
|
return result
|
|
20
22
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class Countdown:
|
|
2
|
+
def __init__(self, start: int):
|
|
3
|
+
self.current = start
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
def __iter__(self):
|
|
7
|
+
return self
|
|
8
|
+
|
|
9
|
+
def __next__(self) -> int:
|
|
10
|
+
|
|
11
|
+
if self.current <= 0:
|
|
12
|
+
raise StopIteration
|
|
13
|
+
else:
|
|
14
|
+
self.current -= 1
|
|
15
|
+
return self.current + 1
|
|
File without changes
|
|
File without changes
|
{brilliant_learn_python-0.1.7 → brilliant_learn_python-0.1.9}/src/brilliant_learn_python/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|