pythonic-fp-circulararray 6.1.1__py3-none-any.whl → 6.2.1__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.
@@ -13,7 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from collections.abc import Callable, Iterable, Iterator
16
- from typing import cast, Final, overload
16
+ from typing import Final, cast, overload
17
+
17
18
  from pythonic_fp.gadgets.sentinels.novalue import NoValue
18
19
 
19
20
  __all__ = ['CA', 'ca']
@@ -30,13 +31,14 @@ class CA[X]:
30
31
  - O(1) indexing, fully supports slicing
31
32
  - auto-resizing more storage capacity when necessary,
32
33
  manually compatible
33
- - iterable but not threadsafe
34
+ - iterable (see __iter__ method below)
34
35
  - comparisons compare identity before equality, like builtins
35
36
  - in boolean context, falsy when empty, otherwise truthy
36
37
  - function ``ca`` produces auto-resizing circular array
37
38
  from arguments
38
39
 
39
40
  """
41
+
40
42
  __slots__ = '_xs', '_cnt', '_cap', '_front', '_rear'
41
43
 
42
44
  def __init__(self, *xs: Iterable[X]) -> None:
@@ -46,7 +48,7 @@ class CA[X]:
46
48
  Populate ``CA`` with an optional iterable
47
49
  from front (left) to rear (right).
48
50
 
49
- :param xs: Takes 0 or 1 iterable parameters.
51
+ :param xs: Takes an optional iterable parameter.
50
52
  :raises ValueError: When more than one parameter is provided.
51
53
  :raises TypeError: When passed a non-iterable parameter.
52
54
 
@@ -83,9 +85,7 @@ class CA[X]:
83
85
  self._front,
84
86
  self._cap,
85
87
  ) = (
86
- self._xs[: self._front]
87
- + [nada] * self._cap
88
- + self._xs[self._front :],
88
+ self._xs[: self._front] + [nada] * self._cap + self._xs[self._front :],
89
89
  self._front + self._cap,
90
90
  2 * self._cap,
91
91
  )
@@ -169,64 +169,17 @@ class CA[X]:
169
169
  """
170
170
  return self._cnt
171
171
 
172
- def __eq__(self, other: object) -> bool:
173
- """
174
- .. admonition:: equality comparison
175
-
176
- Efficiently compare ``CA`` to another object.
177
-
178
- :param other: The object to be compared.
179
- :returns: ``True`` if ``other`` is another ``CA`` whose
180
- contents compare as equal to the corresponding
181
- contents of the ``CA``, otherwise ``False``.
182
-
183
- """
184
- if self is other:
185
- return True
186
- if not isinstance(other, type(self)):
187
- return False
188
-
189
- (
190
- front1,
191
- cnt1,
192
- capacity1,
193
- front2,
194
- cnt2,
195
- capacity2,
196
- ) = (
197
- self._front,
198
- self._cnt,
199
- self._cap,
200
- other._front,
201
- other._cnt,
202
- other._cap,
203
- )
204
-
205
- if cnt1 != cnt2:
206
- return False
207
-
208
- for nn in range(cnt1):
209
- if (
210
- self._xs[(front1 + nn) % capacity1]
211
- is other._xs[(front2 + nn) % capacity2]
212
- ):
213
- continue
214
- if (
215
- self._xs[(front1 + nn) % capacity1]
216
- != other._xs[(front2 + nn) % capacity2]
217
- ):
218
- return False
219
- return True
220
-
221
172
  def __iter__(self) -> Iterator[X]:
222
173
  """
223
174
  .. admonition:: iterate
224
175
 
225
- Iterates circular array, front (left) to rear (right).
176
+ Iterates circular array, left (front) to right (rear).
226
177
 
227
- .. warning
178
+ :yields: The ``CA`` contents front to rear.
228
179
 
229
- Not thread safe, especially for long living iterators.
180
+ .. warning::
181
+
182
+ Not threadsafe, especially for long living iterators.
230
183
 
231
184
  .. tip::
232
185
 
@@ -257,7 +210,9 @@ class CA[X]:
257
210
  """
258
211
  .. admonition:: reverse iterate
259
212
 
260
- Iterates circular array, rear (right) to front (left).
213
+ Iterates circular array, right (rear) to left (front).
214
+
215
+ :yields: The ``CA`` contents right to left.
261
216
 
262
217
  .. warning
263
218
 
@@ -288,6 +243,55 @@ class CA[X]:
288
243
  position = (position - 1) % capacity
289
244
  yield cast(X, current_state[position])
290
245
 
246
+ def __eq__(self, other: object) -> bool:
247
+ """
248
+ .. admonition:: equality comparison
249
+
250
+ Efficiently compare ``CA`` to another object.
251
+
252
+ :param other: The object to be compared.
253
+ :returns: ``True`` if ``other`` is another ``CA`` whose
254
+ contents compare as equal to the corresponding
255
+ contents of the ``CA``, otherwise ``False``.
256
+
257
+ """
258
+ if self is other:
259
+ return True
260
+ if not isinstance(other, type(self)):
261
+ return False
262
+
263
+ (
264
+ front1,
265
+ cnt1,
266
+ capacity1,
267
+ front2,
268
+ cnt2,
269
+ capacity2,
270
+ ) = (
271
+ self._front,
272
+ self._cnt,
273
+ self._cap,
274
+ other._front,
275
+ other._cnt,
276
+ other._cap,
277
+ )
278
+
279
+ if cnt1 != cnt2:
280
+ return False
281
+
282
+ for nn in range(cnt1):
283
+ if (
284
+ self._xs[(front1 + nn) % capacity1]
285
+ is other._xs[(front2 + nn) % capacity2]
286
+ ):
287
+ continue
288
+ if (
289
+ self._xs[(front1 + nn) % capacity1]
290
+ != other._xs[(front2 + nn) % capacity2]
291
+ ):
292
+ return False
293
+ return True
294
+
291
295
  @overload
292
296
  def __getitem__(self, idx: int) -> X: ...
293
297
  @overload
@@ -408,7 +412,7 @@ class CA[X]:
408
412
  Construct string 'CA(x₁, x₂, … xₙ)' where
409
413
  x₁, x₂, … xₙ are the contents displayed with ``repr()``.
410
414
 
411
- :returns: A string to reproduce the ``CA``.
415
+ :returns: A string to reproduce the ``CA``.
412
416
 
413
417
  """
414
418
  return 'ca(' + ', '.join(map(repr, self)) + ')'
@@ -420,7 +424,7 @@ class CA[X]:
420
424
  Construct string '(\| x₁, x₂, … xₙ \|)' where
421
425
  x₁, x₂, ..., xₙ are the contents displayed with ``str()``.
422
426
 
423
- :returns: A estring meaningful to an end user.
427
+ :returns: A string meaningful to an end user.
424
428
 
425
429
  """
426
430
  return '(| ' + ', '.join(map(str, self)) + ' |)'
@@ -7,9 +7,9 @@ class CA[X]:
7
7
  def __init__(self, *xs: Iterable[X]) -> None: ...
8
8
  def __bool__(self) -> bool: ...
9
9
  def __len__(self) -> int: ...
10
- def __eq__(self, other: object) -> bool: ...
11
10
  def __iter__(self) -> Iterator[X]: ...
12
11
  def __reversed__(self) -> Iterator[X]: ...
12
+ def __eq__(self, other: object) -> bool: ...
13
13
  @overload
14
14
  def __getitem__(self, idx: int) -> X: ...
15
15
  @overload
@@ -13,7 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from collections.abc import Callable, Iterable, Iterator
16
- from typing import cast, Final, overload
16
+ from typing import Final, cast, overload
17
+
17
18
  from pythonic_fp.gadgets.sentinels.novalue import NoValue
18
19
 
19
20
  __all__ = ['CAF', 'caf']
@@ -22,14 +23,13 @@ nada: Final[NoValue] = NoValue()
22
23
 
23
24
 
24
25
  class CAF[X]:
25
-
26
26
  """
27
27
  .. admonition:: Fixed storage capacity circular array CAF
28
28
 
29
29
  - O(1) pops and pushes either end
30
30
  - O(1) indexing, does not support slicing
31
31
  - fixed total storage capacity
32
- - iterable but not threadsafe
32
+ - iterable (see __iter__ method below)
33
33
  - comparisons compare identity before equality, like builtins
34
34
  - in boolean context, falsy when either empty or full,
35
35
  otherwise truthy
@@ -37,6 +37,7 @@ class CAF[X]:
37
37
  from arguments
38
38
 
39
39
  """
40
+
40
41
  __slots__ = '_xs', '_cnt', '_cap', '_front', '_rear'
41
42
 
42
43
  def __init__(self, *xs: Iterable[X], cap: int = 2) -> None:
@@ -46,7 +47,7 @@ class CAF[X]:
46
47
  Populate ``CAF`` with an optional iterable
47
48
  from front (left) to rear (right).
48
49
 
49
- :param xs: Takes 0 or 1 iterable parameters.
50
+ :param xs: Takes an optional iterable parameter.
50
51
  :raises ValueError: When more than one parameter is provided.
51
52
  :raises TypeError: When passed a non-iterable parameter.
52
53
 
@@ -96,64 +97,17 @@ class CAF[X]:
96
97
  """
97
98
  return self._cnt
98
99
 
99
- def __eq__(self, other: object) -> bool:
100
- """
101
- .. admonition:: equality comparison
102
-
103
- Efficiently compare ``CAF`` to another object.
104
-
105
- :param other: The object to be compared.
106
- :returns: ``True`` if ``other`` is another ``CAF`` whose
107
- contents compare as equal to the corresponding
108
- contents of the ``CAF``, otherwise ``False``.
109
-
110
- """
111
- if self is other:
112
- return True
113
- if not isinstance(other, type(self)):
114
- return False
115
-
116
- (
117
- front1,
118
- cnt1,
119
- cap1,
120
- front2,
121
- cnt2,
122
- cap2,
123
- ) = (
124
- self._front,
125
- self._cnt,
126
- self._cap,
127
- other._front,
128
- other._cnt,
129
- other._cap,
130
- )
131
-
132
- if cnt1 != cnt2:
133
- return False
134
-
135
- for nn in range(cnt1):
136
- if (
137
- self._xs[(front1 + nn) % cap1]
138
- is other._xs[(front2 + nn) % cap2]
139
- ):
140
- continue
141
- if (
142
- self._xs[(front1 + nn) % cap1]
143
- != other._xs[(front2 + nn) % cap2]
144
- ):
145
- return False
146
- return True
147
-
148
100
  def __iter__(self) -> Iterator[X]:
149
101
  """
150
102
  .. admonition:: iterate
151
103
 
152
- Iterates circular array, front (left) to rear (right).
104
+ Iterates circular array, left (front) to right (rear).
153
105
 
154
- .. warning
106
+ :yields: The ``CA`` contents front to rear.
155
107
 
156
- Not thread safe, especially for long living iterators.
108
+ .. warning::
109
+
110
+ Not threadsafe, especially for long living iterators.
157
111
 
158
112
  .. tip::
159
113
 
@@ -184,7 +138,9 @@ class CAF[X]:
184
138
  """
185
139
  .. admonition:: reverse iterate
186
140
 
187
- Iterates circular array, rear (right) to front (left).
141
+ Iterates circular array, right (rear) to left (front).
142
+
143
+ :yields: The ``CAF`` contents rear to front.
188
144
 
189
145
  .. warning
190
146
 
@@ -215,6 +171,49 @@ class CAF[X]:
215
171
  position = (position - 1) % cap
216
172
  yield cast(X, current_state[position])
217
173
 
174
+ def __eq__(self, other: object) -> bool:
175
+ """
176
+ .. admonition:: equality comparison
177
+
178
+ Efficiently compare ``CAF`` to another object.
179
+
180
+ :param other: The object to be compared.
181
+ :returns: ``True`` if ``other`` is another ``CAF`` whose
182
+ contents compare as equal to the corresponding
183
+ contents of the ``CAF``, otherwise ``False``.
184
+
185
+ """
186
+ if self is other:
187
+ return True
188
+ if not isinstance(other, type(self)):
189
+ return False
190
+
191
+ (
192
+ front1,
193
+ cnt1,
194
+ cap1,
195
+ front2,
196
+ cnt2,
197
+ cap2,
198
+ ) = (
199
+ self._front,
200
+ self._cnt,
201
+ self._cap,
202
+ other._front,
203
+ other._cnt,
204
+ other._cap,
205
+ )
206
+
207
+ if cnt1 != cnt2:
208
+ return False
209
+
210
+ for nn in range(cnt1):
211
+ if self._xs[(front1 + nn) % cap1] is other._xs[(front2 + nn) % cap2]:
212
+ continue
213
+ if self._xs[(front1 + nn) % cap1] != other._xs[(front2 + nn) % cap2]:
214
+ return False
215
+ return True
216
+
218
217
  def __getitem__(self, idx: int) -> X:
219
218
  """
220
219
  .. admonition:: getitem
@@ -271,7 +270,7 @@ class CAF[X]:
271
270
  """
272
271
  item_list = list(self)
273
272
  del item_list[idx]
274
- _ca = CAF(item_list, cap = self._cap)
273
+ _ca = CAF(item_list, cap=self._cap)
275
274
  (
276
275
  self._xs,
277
276
  self._cnt,
@@ -562,7 +561,7 @@ class CAF[X]:
562
561
  :returns: New fixed capacity circular array instance.
563
562
 
564
563
  """
565
- return CAF(map(f, self), cap = self._cap)
564
+ return CAF(map(f, self), cap=self._cap)
566
565
 
567
566
  @overload
568
567
  def foldl[L](self, f: Callable[[X, X], X]) -> X: ...
@@ -7,9 +7,9 @@ class CAF[X]:
7
7
  def __init__(self, *xs: Iterable[X], cap: int = 2) -> None: ...
8
8
  def __bool__(self) -> bool: ...
9
9
  def __len__(self) -> int: ...
10
- def __eq__(self, other: object) -> bool: ...
11
10
  def __iter__(self) -> Iterator[X]: ...
12
11
  def __reversed__(self) -> Iterator[X]: ...
12
+ def __eq__(self, other: object) -> bool: ...
13
13
  def __getitem__(self, idx: int) -> X: ...
14
14
  def __setitem__(self, idx: int, val: X) -> None: ...
15
15
  def __delitem__(self, idx: int) -> None: ...
@@ -1,38 +1,39 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonic-fp-circulararray
3
- Version: 6.1.1
4
- Summary: Circular Array
3
+ Version: 6.2.1
4
+ Summary: Circular array datastructures.
5
5
  Keywords: auto resizing,circular array,circulararray,dequeue,indexable,pop,push
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
7
- Requires-Python: >=3.13
8
- Description-Content-Type: text/x-rst
7
+ Requires-Python: >=3.14
8
+ Description-Content-Type: text/markdown
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Framework :: Pytest
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
15
16
  Classifier: Typing :: Typed
16
17
  License-File: LICENSE
17
18
  Requires-Dist: pythonic-fp-gadgets>=4.0.2
18
- Requires-Dist: pytest>=8.4.1 ; extra == "test"
19
- Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-circulararray/blob/main/CHANGELOG.rst
20
- Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/projects/circulararray.html
19
+ Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-circulararray/blob/main/CHANGELOG.md
20
+ Project-URL: Documentation, https://grscheller.github.io/pythonic-fp-circulararray/release/html/
21
21
  Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/
22
22
  Project-URL: Source, https://github.com/grscheller/pythonic-fp-circulararray
23
- Provides-Extra: test
24
23
 
25
- Pythonic FP - Circular Array
26
- ============================
24
+ # Pythonic FP - Circular Array
25
+
26
+ Stateful circular array data structures.
27
27
 
28
28
  PyPI project
29
- `pythonic-fp-circulararray
30
- <https://pypi.org/project/pythonic-fp-circulararray>`_.
29
+ [pythonic-fp-circulararray](https://pypi.org/project/pythonic-fp-circulararray).
30
+ Part of the
31
+ [pythonic-fp](https://grscheller.github.io/pythonic-fp/)
32
+ PyPI projects.
31
33
 
32
- Python module implementing stateful circular array data structures.
34
+ ## Description
33
35
 
34
36
  - variable storage capacity circular array
35
-
36
37
  - O(1) pops either end
37
38
  - O(1) amortized pushes either end
38
39
  - O(1) indexing, fully supports slicing
@@ -41,9 +42,7 @@ Python module implementing stateful circular array data structures.
41
42
  - comparisons compare identity before equality, like builtins
42
43
  - in boolean context, falsy when empty, otherwise truthy
43
44
  - function ``ca`` produces auto-resizing circular array from arguments
44
-
45
45
  - fixed storage capacity circular array
46
-
47
46
  - O(1) pops and pushes either end
48
47
  - O(1) indexing, does not support slicing
49
48
  - fixed total storage capacity
@@ -52,20 +51,7 @@ Python module implementing stateful circular array data structures.
52
51
  - in boolean context, falsy when either empty or full, otherwise truthy
53
52
  - function ``caf`` produces fixed capacity circular array from arguments
54
53
 
55
- Part of the
56
- `pythonic-fp
57
- <https://grscheller.github.io/pythonic-fp/>`_
58
- PyPI projects.
59
-
60
- Documentation
61
- -------------
62
-
63
- Documentation and other links for this project are hosted on
64
- `GitHub Pages
65
- <https://grscheller.github.io/pythonic-fp/projects/circulararray.html>`_.
66
-
67
- Copyright and License
68
- ---------------------
54
+ ## Copyright and License
69
55
 
70
56
  Copyright (c) 2023-2026 Geoffrey R. Scheller. Licensed under the Apache
71
57
  License, Version 2.0. See the LICENSE file for details.
@@ -0,0 +1,11 @@
1
+ pythonic_fp/circulararray/__init__.py,sha256=PJsikfFReHq2QXpmcg_AYeBbuyauGjfJ9bBdc2YNtzo,1016
2
+ pythonic_fp/circulararray/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pythonic_fp/circulararray/auto.py,sha256=xOZV5v_MQJFBz76l4H2zOCFQHDWz7nP90y1P8g7zjF0,23883
4
+ pythonic_fp/circulararray/auto.pyi,sha256=M1gGKXsTifzinGTU9UH2LUfEb5-ki_jSFwtzeuXlEfA,1786
5
+ pythonic_fp/circulararray/fixed.py,sha256=BoHokzCY-UxFYeVkLAhvw7aeSWGn_ct2WD5IOjE4C3U,19786
6
+ pythonic_fp/circulararray/fixed.pyi,sha256=05-A1T91VIhOTAXqUNMQLolM4pMZ2HgEaRHkqg8V9os,1497
7
+ pythonic_fp/circulararray/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pythonic_fp_circulararray-6.2.1.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
9
+ pythonic_fp_circulararray-6.2.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
10
+ pythonic_fp_circulararray-6.2.1.dist-info/METADATA,sha256=37XgIgjczhdXlI-gDnRJIzB0-bBC7Hy4DQFvT-9iv-M,2456
11
+ pythonic_fp_circulararray-6.2.1.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- pythonic_fp/circulararray/__init__.py,sha256=PJsikfFReHq2QXpmcg_AYeBbuyauGjfJ9bBdc2YNtzo,1016
2
- pythonic_fp/circulararray/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- pythonic_fp/circulararray/auto.py,sha256=ihXv7hYX5zdr8wHZd8iEIx-TldnV42FdzNchaUT-kVw,23787
4
- pythonic_fp/circulararray/auto.pyi,sha256=JHc72vNNMDgV46C5xM7V4ghgGwcmRXjKu8lI4ho-ogw,1786
5
- pythonic_fp/circulararray/fixed.py,sha256=WZa4duooDGWlizfkxBJD52NULGVTrZsd7TRkH4OiGAY,19756
6
- pythonic_fp/circulararray/fixed.pyi,sha256=T__Xqq66xf5AoUiMJU9ytveEaBaXMM-WuEw1q3AFjEY,1497
7
- pythonic_fp/circulararray/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- pythonic_fp_circulararray-6.1.1.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
9
- pythonic_fp_circulararray-6.1.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
10
- pythonic_fp_circulararray-6.1.1.dist-info/METADATA,sha256=H3J7lPw3gx2Xl9E3TwKCD_Gbz2Q7-fudOQ1ZnRbkKE0,2699
11
- pythonic_fp_circulararray-6.1.1.dist-info/RECORD,,