relib 1.3.7__tar.gz → 1.3.8__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.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,6 +1,6 @@
1
1
  [project]
2
2
  name = "relib"
3
- version = "1.3.7"
3
+ version = "1.3.8"
4
4
  requires-python = ">=3.10"
5
5
  dependencies = []
6
6
  authors = [
@@ -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]:
@@ -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
@@ -161,7 +161,7 @@ wheels = [
161
161
 
162
162
  [[package]]
163
163
  name = "relib"
164
- version = "1.3.7"
164
+ version = "1.3.8"
165
165
  source = { editable = "." }
166
166
 
167
167
  [package.dev-dependencies]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes