dycw-utilities 0.151.4__py3-none-any.whl → 0.151.5__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.
- {dycw_utilities-0.151.4.dist-info → dycw_utilities-0.151.5.dist-info}/METADATA +1 -1
- {dycw_utilities-0.151.4.dist-info → dycw_utilities-0.151.5.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/atools.py +64 -4
- {dycw_utilities-0.151.4.dist-info → dycw_utilities-0.151.5.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.151.4.dist-info → dycw_utilities-0.151.5.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.151.4.dist-info → dycw_utilities-0.151.5.dist-info}/licenses/LICENSE +0 -0
@@ -1,8 +1,8 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=rDAnptLaac5YF9rfpSwzN4NUEf8bMIfdG3fz1V7gxO0,60
|
2
2
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
3
3
|
utilities/asyncio.py,sha256=2m2a2C-Qgc6OHTTHL332-t66A7xDITt_SORT7a1DJWo,16792
|
4
4
|
utilities/atomicwrites.py,sha256=xcOWenTBRS0oat3kg7Sqe51AohNThMQ2ixPL7QCG8hw,5795
|
5
|
-
utilities/atools.py,sha256=
|
5
|
+
utilities/atools.py,sha256=6neeCcgXxK2dlsc0xp15Za7nSucbCgFtAJepGI_-WXU,2549
|
6
6
|
utilities/cachetools.py,sha256=v1-9sXHLdOLiwmkq6NB0OUbxeKBuVVN6wmAWefWoaHI,2744
|
7
7
|
utilities/click.py,sha256=4godcta2Ozm-s3VvIXeNgoBlK2NIz_Q0XfAq64vAfZY,17369
|
8
8
|
utilities/concurrent.py,sha256=ZdhcNeBl1-HaAPY3h7bZ5ccuYdfdq2ATHplvZdnzlhk,2858
|
@@ -89,8 +89,8 @@ utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
|
|
89
89
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
90
90
|
utilities/pytest_plugins/pytest_randomly.py,sha256=NXzCcGKbpgYouz5yehKb4jmxmi2SexKKpgF4M65bi10,414
|
91
91
|
utilities/pytest_plugins/pytest_regressions.py,sha256=Iwhfv_OJH7UCPZCfoh7ugZ2Xjqjil-BBBsOb8sDwiGI,1471
|
92
|
-
dycw_utilities-0.151.
|
93
|
-
dycw_utilities-0.151.
|
94
|
-
dycw_utilities-0.151.
|
95
|
-
dycw_utilities-0.151.
|
96
|
-
dycw_utilities-0.151.
|
92
|
+
dycw_utilities-0.151.5.dist-info/METADATA,sha256=tLKFv_elmyBCNcoGEMtAlYBcrLLlXhwKqNFIJ_-c6CA,1696
|
93
|
+
dycw_utilities-0.151.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
94
|
+
dycw_utilities-0.151.5.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
95
|
+
dycw_utilities-0.151.5.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
96
|
+
dycw_utilities-0.151.5.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/atools.py
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
from collections.abc import Callable
|
4
|
-
from
|
4
|
+
from functools import partial
|
5
|
+
from pathlib import Path
|
6
|
+
from typing import TYPE_CHECKING, Any, cast, overload
|
5
7
|
|
6
|
-
|
8
|
+
import atools
|
9
|
+
from whenever import TimeDelta
|
7
10
|
|
8
|
-
from utilities.types import Coro
|
11
|
+
from utilities.types import Coro, PathLike
|
9
12
|
|
10
13
|
if TYPE_CHECKING:
|
11
|
-
from
|
14
|
+
from atools._memoize_decorator import Keygen, Pickler
|
12
15
|
|
13
16
|
|
14
17
|
type _Key[**P, T] = tuple[Callable[P, Coro[T]], TimeDelta]
|
@@ -36,4 +39,61 @@ async def call_memoized[**P, T](
|
|
36
39
|
return await memoized_func(*args, **kwargs)
|
37
40
|
|
38
41
|
|
42
|
+
##
|
43
|
+
|
44
|
+
|
45
|
+
@overload
|
46
|
+
def memoize[F: Callable[..., Coro[Any]]](
|
47
|
+
func: F,
|
48
|
+
/,
|
49
|
+
*,
|
50
|
+
db_path: PathLike | None = None,
|
51
|
+
duration: float | TimeDelta | None = None,
|
52
|
+
keygen: Keygen | None = None,
|
53
|
+
pickler: Pickler | None = None,
|
54
|
+
size: int | None = None,
|
55
|
+
) -> F: ...
|
56
|
+
@overload
|
57
|
+
def memoize[F: Callable[..., Coro[Any]]](
|
58
|
+
func: None = None,
|
59
|
+
/,
|
60
|
+
*,
|
61
|
+
db_path: PathLike | None = None,
|
62
|
+
duration: float | TimeDelta | None = None,
|
63
|
+
keygen: Keygen | None = None,
|
64
|
+
pickler: Pickler | None = None,
|
65
|
+
size: int | None = None,
|
66
|
+
) -> Callable[[F], F]: ...
|
67
|
+
def memoize[F: Callable[..., Coro[Any]]](
|
68
|
+
func: F | None = None,
|
69
|
+
/,
|
70
|
+
*,
|
71
|
+
db_path: PathLike | None = None,
|
72
|
+
duration: float | TimeDelta | None = None,
|
73
|
+
keygen: Keygen | None = None,
|
74
|
+
pickler: Pickler | None = None,
|
75
|
+
size: int | None = None,
|
76
|
+
) -> F | Callable[[F], F]:
|
77
|
+
"""Memoize a function."""
|
78
|
+
if func is None:
|
79
|
+
result = partial(
|
80
|
+
memoize,
|
81
|
+
db_path=db_path,
|
82
|
+
duration=duration,
|
83
|
+
keygen=keygen,
|
84
|
+
pickler=pickler,
|
85
|
+
size=size,
|
86
|
+
)
|
87
|
+
return cast("Callable[[F], F]", result)
|
88
|
+
return atools.memoize(
|
89
|
+
db_path=None if db_path is None else Path(db_path),
|
90
|
+
duration=duration.py_timedelta()
|
91
|
+
if isinstance(duration, TimeDelta)
|
92
|
+
else duration,
|
93
|
+
keygen=keygen,
|
94
|
+
pickler=pickler,
|
95
|
+
size=size,
|
96
|
+
)(func)
|
97
|
+
|
98
|
+
|
39
99
|
__all__ = ["call_memoized"]
|
File without changes
|
File without changes
|
File without changes
|