relib 1.3.7__py3-none-any.whl → 1.3.8__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.
- relib/dict_utils.py +5 -2
- relib/iter_utils.py +9 -1
- {relib-1.3.7.dist-info → relib-1.3.8.dist-info}/METADATA +1 -1
- {relib-1.3.7.dist-info → relib-1.3.8.dist-info}/RECORD +6 -6
- {relib-1.3.7.dist-info → relib-1.3.8.dist-info}/WHEEL +0 -0
- {relib-1.3.7.dist-info → relib-1.3.8.dist-info}/licenses/LICENSE +0 -0
relib/dict_utils.py
CHANGED
@@ -24,11 +24,14 @@ def merge_dicts(*dicts: dict[K, T]) -> dict[K, T]:
|
|
24
24
|
result |= d
|
25
25
|
return result
|
26
26
|
|
27
|
-
def omit(d: dict[K, T], keys: Iterable[K]) -> dict[K, T]:
|
27
|
+
def omit(d: dict[K, T], keys: Iterable[K], optional=False) -> dict[K, T]:
|
28
28
|
if keys:
|
29
29
|
d = dict(d)
|
30
30
|
for key in keys:
|
31
|
-
|
31
|
+
try:
|
32
|
+
del d[key]
|
33
|
+
except KeyError if optional else ():
|
34
|
+
pass
|
32
35
|
return d
|
33
36
|
|
34
37
|
def pick(d: dict[K, T], keys: Iterable[K]) -> dict[K, T]:
|
relib/iter_utils.py
CHANGED
@@ -14,7 +14,7 @@ __all__ = [
|
|
14
14
|
"list_split",
|
15
15
|
"move_value",
|
16
16
|
"partition",
|
17
|
-
"reversed_enumerate",
|
17
|
+
"range_of", "reversed_enumerate",
|
18
18
|
"seekable", "sort_by",
|
19
19
|
"transpose",
|
20
20
|
]
|
@@ -73,6 +73,9 @@ def partition(iterable: Iterable[tuple[bool, T]]) -> tuple[list[T], list[T]]:
|
|
73
73
|
false_values.append(value)
|
74
74
|
return true_values, false_values
|
75
75
|
|
76
|
+
def range_of(values: Sequence) -> range:
|
77
|
+
return range(len(values))
|
78
|
+
|
76
79
|
class seekable(Generic[T]):
|
77
80
|
def __init__(self, iterable: Iterable[T]):
|
78
81
|
self.index = 0
|
@@ -123,6 +126,11 @@ class seekable(Generic[T]):
|
|
123
126
|
with self.freeze():
|
124
127
|
return list(islice(self, count))
|
125
128
|
|
129
|
+
def forgetful(self) -> Iterable[T]:
|
130
|
+
for value in self:
|
131
|
+
self.clear()
|
132
|
+
yield value
|
133
|
+
|
126
134
|
@overload
|
127
135
|
def chunked(values: Iterable[T], *, num_chunks: int, chunk_size=None) -> list[list[T]]: ...
|
128
136
|
@overload
|
@@ -1,12 +1,12 @@
|
|
1
1
|
relib/__init__.py,sha256=WerjUaM_sNvudjXFudLRtXB7viZWEW1RSinkDjrh4nE,163
|
2
|
-
relib/dict_utils.py,sha256=
|
2
|
+
relib/dict_utils.py,sha256=ez8egTPvO05wVNWIyO-aJjtqaXUDYbzyw32M42q1D44,3677
|
3
3
|
relib/io_utils.py,sha256=cUyUFhrMCUDfkINhYo32QPaVGz3chqDO3ElymSCoWEg,1086
|
4
|
-
relib/iter_utils.py,sha256=
|
4
|
+
relib/iter_utils.py,sha256=G-e1XBfwNvhoA5UhuOW7sfDB16jZ9469HWeByp4bmX0,5936
|
5
5
|
relib/processing_utils.py,sha256=kFb4izrR8vec9BFWeGSb-TXR54bbA4X3dxAfIBZItuI,1911
|
6
6
|
relib/runtime_tools.py,sha256=6HpRXmAHHLq4bNRj6fSiaLQeHR2h3OdxFZxaB93fXhI,2979
|
7
7
|
relib/type_utils.py,sha256=68yEhEIBCIKfsIT1u647avHVA_JjVvDYSdtLD3nCrJs,338
|
8
8
|
relib/types.py,sha256=JzSGDl2L6tUWizGSsUpuyCKf-VKgtgfK_n21azSSMLM,288
|
9
|
-
relib-1.3.
|
10
|
-
relib-1.3.
|
11
|
-
relib-1.3.
|
12
|
-
relib-1.3.
|
9
|
+
relib-1.3.8.dist-info/METADATA,sha256=iooKfH_eo37W8TvLHhVq4alan0cSMLI0U-gRSu7h2Ok,1295
|
10
|
+
relib-1.3.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
+
relib-1.3.8.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
|
12
|
+
relib-1.3.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|