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 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
- del d[key]
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relib
3
- Version: 1.3.7
3
+ Version: 1.3.8
4
4
  Project-URL: Repository, https://github.com/Reddan/relib.git
5
5
  Author: Hampus Hallman
6
6
  License: Copyright 2018-2025 Hampus Hallman
@@ -1,12 +1,12 @@
1
1
  relib/__init__.py,sha256=WerjUaM_sNvudjXFudLRtXB7viZWEW1RSinkDjrh4nE,163
2
- relib/dict_utils.py,sha256=EUfZi8sw_30Z4xtfyJYFy1COtDXGl6H5cya9X4ZyifI,3592
2
+ relib/dict_utils.py,sha256=ez8egTPvO05wVNWIyO-aJjtqaXUDYbzyw32M42q1D44,3677
3
3
  relib/io_utils.py,sha256=cUyUFhrMCUDfkINhYo32QPaVGz3chqDO3ElymSCoWEg,1086
4
- relib/iter_utils.py,sha256=V0Sq64JM6M_g5yJvUVGhhLZ-v0x9RY0X8JpyVb_Iuxo,5755
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.7.dist-info/METADATA,sha256=k2jncYQhiZXcQV12Bjev_1QmA148Cu6YP4iRIVhV0uo,1295
10
- relib-1.3.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
- relib-1.3.7.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
12
- relib-1.3.7.dist-info/RECORD,,
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