dtools.circular-array 3.11.0__py3-none-any.whl → 3.12.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.
@@ -12,23 +12,22 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- """### Developer Tools - circular array data structure
15
+ """### Developer Tools - Circular Array Data Structure
16
16
 
17
17
  Package for an indexable, sliceable, auto-resizing circular array
18
18
  data structure with amortized O(1) pushes and pops either end.
19
19
 
20
- #### Circular Array Data Structure
20
+ Circular array data structure.
21
21
 
22
- * *module* dtools.circular_array.ca
23
- * circular array data structure
24
- * *class* dtools.circular_array.ca.CA
25
- * initializer takes 1 or 0 iterables
26
- * *function* dtools.circular_array.ca.ca
27
- * factory function taking a variable number of arguments
22
+ - *module* dtools.circular_array
23
+ - *class* dtools.circular_array.ca.CA
24
+ - initializer takes up to 1 iterable
25
+ - *function* dtools.circular_array.ca.ca
26
+ - factory function taking a variable number of arguments
28
27
 
29
28
  """
30
29
 
31
- __version__ = '3.11.0'
30
+ __version__ = '3.12.1'
32
31
  __author__ = 'Geoffrey R. Scheller'
33
32
  __copyright__ = 'Copyright (c) 2023-2025 Geoffrey R. Scheller'
34
33
  __license__ = 'Apache License 2.0'
@@ -15,18 +15,19 @@
15
15
  """### Module for an indexable circular array data structure."""
16
16
 
17
17
  from __future__ import annotations
18
- from collections.abc import Callable, Iterable, Iterator, Sequence
18
+ from collections.abc import Callable, Iterable, Iterator
19
19
  from typing import cast, Never, overload, TypeVar
20
20
 
21
21
  __all__ = ['CA', 'ca']
22
22
 
23
- D = TypeVar('D') # type: ignore[unused-ignore] # Needed only for pdoc
24
- L = TypeVar('L') # type: ignore[unused-ignore] # documentation generation.
25
- R = TypeVar('R') # type: ignore[unused-ignore] # Otherwise, not needed
26
- U = TypeVar('U') # type: ignore[unused-ignore] # by either MyPy or Python.
23
+ D = TypeVar('D') # Needed only for pdoc documentation generation. Otherwise,
24
+ L = TypeVar('L') # ignored by both MyPy and Python. Makes linters unhappy
25
+ R = TypeVar('R') # when these are used on function and method signatures due
26
+ U = TypeVar('U') # to "redefined-outer-name" warnings. Function and method
27
+ T = TypeVar('T') # signatures do not support variance and bounds constraints.
27
28
 
28
29
 
29
- class CA[D](Sequence[D]):
30
+ class CA[D]():
30
31
  """Indexable circular array data structure
31
32
 
32
33
  - generic, stateful data structure
@@ -349,7 +350,7 @@ class CA[D](Sequence[D]):
349
350
  except ValueError:
350
351
  return default
351
352
 
352
- def poplt(self, maximum: int) -> tuple[D, ...]:
353
+ def poplt(self, maximum: int, /) -> tuple[D, ...]:
353
354
  """Pop multiple values from left side of `CA`.
354
355
 
355
356
  - returns the results in a tuple of type `tuple[~D, ...]`
@@ -370,7 +371,7 @@ class CA[D](Sequence[D]):
370
371
 
371
372
  return tuple(ds)
372
373
 
373
- def poprt(self, max: int) -> tuple[D, ...]:
374
+ def poprt(self, maximum: int, /) -> tuple[D, ...]:
374
375
  """Pop multiple values from right side of `CA`.
375
376
 
376
377
  - returns the results in a tuple of type `tuple[~D, ...]`
@@ -380,31 +381,29 @@ class CA[D](Sequence[D]):
380
381
 
381
382
  """
382
383
  ds: list[D] = []
383
- while max > 0:
384
+ while maximum > 0:
384
385
  try:
385
386
  ds.append(self.popr())
386
387
  except ValueError:
387
388
  break
388
389
  else:
389
- max -= 1
390
+ maximum -= 1
390
391
 
391
392
  return tuple(ds)
392
393
 
393
- def rotl(self, n: int = 1) -> None:
394
+ def rotl(self, n: int = 1, /) -> None:
394
395
  """Rotate `CA` arguments left n times."""
395
396
  if self._cnt < 2:
396
397
  return
397
- while n > 0:
398
+ for _ in range(n, 0, -1):
398
399
  self.pushr(self.popl())
399
- n -= 1
400
400
 
401
- def rotr(self, n: int = 1) -> None:
401
+ def rotr(self, n: int = 1, /) -> None:
402
402
  """Rotate `CA` arguments right n times."""
403
403
  if self._cnt < 2:
404
404
  return
405
- while n > 0:
405
+ for _ in range(n, 0, -1):
406
406
  self.pushl(self.popr())
407
- n -= 1
408
407
 
409
408
  def map[U](self, f: Callable[[D], U], /) -> CA[U]:
410
409
  """Apply function f over contents, returns new `CA` instance.
@@ -488,7 +487,7 @@ class CA[D](Sequence[D]):
488
487
  def resize(self, minimum_capacity: int = 2) -> None:
489
488
  """Compact `CA` and resize to `minimum_capacity` if necessary.
490
489
 
491
- To just compact the `CA`, do not provide a minimum capacity.
490
+ * to just compact the `CA`, do not provide a minimum capacity
492
491
 
493
492
  """
494
493
  self._compact_storage_capacity()
@@ -498,6 +497,6 @@ class CA[D](Sequence[D]):
498
497
  self._front, self._rear = 0, self._cap - 1
499
498
 
500
499
 
501
- def ca[D](*ds: D) -> CA[D]:
500
+ def ca[T](*ds: T) -> CA[T]:
502
501
  """Function to produce a `CA` array from a variable number of arguments."""
503
502
  return CA(ds)
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dtools.circular-array
3
- Version: 3.11.0
4
- Summary: ### Developer Tools - circular array data structure
3
+ Version: 3.12.1
4
+ Summary: ### Developer Tools - Circular Array Data Structure
5
5
  Keywords: circular array,circle array,CA,dequeue,dqueue,FIFO,LIFO,pop,push,indexable,auto-resizing,auto resizing,resizing
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
7
7
  Requires-Python: >=3.12
@@ -61,7 +61,7 @@ syntactic sugar like `[]` or `{}`.
61
61
  #### Usage
62
62
 
63
63
  ```python
64
- from dtools.circular_array.ca import CA
64
+ from dtools.circular_array.ca import CA, ca
65
65
 
66
66
  ca1 = ca(1, 2, 3)
67
67
  assert ca1.popl() == 1
@@ -0,0 +1,7 @@
1
+ dtools/circular_array/__init__.py,sha256=2CvFEORjHTaRYTteVH-Ifo7THhbttgif71VigBM-3-Y,1189
2
+ dtools/circular_array/ca.py,sha256=PRt-AOvR9WqwS6EdKFWXde7VxBc1yOD6kuCK_lXuWFQ,16683
3
+ dtools/circular_array/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ dtools_circular_array-3.12.1.dist-info/licenses/LICENSE,sha256=csqbZRvA3Nyuav1aszWvswE8CZtaKr-hMjjjcKqms7w,10774
5
+ dtools_circular_array-3.12.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
6
+ dtools_circular_array-3.12.1.dist-info/METADATA,sha256=9HGyzkYTReGc9LUbP_X1qbWEK-EQKVwA_gAaZdI_5cI,3495
7
+ dtools_circular_array-3.12.1.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- dtools/circular_array/__init__.py,sha256=JfokAp0Jh8b5oU6aYQKNG1_8FB1OFT4geAowCLQSGQ0,1222
2
- dtools/circular_array/ca.py,sha256=nAyi-fuIriMt2R08Ibq_KCdKuMNM199hTfye7Ap9qj8,16604
3
- dtools/circular_array/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- dtools_circular_array-3.11.0.dist-info/licenses/LICENSE,sha256=csqbZRvA3Nyuav1aszWvswE8CZtaKr-hMjjjcKqms7w,10774
5
- dtools_circular_array-3.11.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
6
- dtools_circular_array-3.11.0.dist-info/METADATA,sha256=lE6GWKO2BQU_EEKseM5UKSLqsz5Rc-s8YdAiQt8Gjvw,3491
7
- dtools_circular_array-3.11.0.dist-info/RECORD,,