bitarray 3.8.2__tar.gz → 3.9.1__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: bitarray
3
- Version: 3.8.2
3
+ Version: 3.9.1
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -19,8 +19,9 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Programming Language :: Python :: 3.14
22
- Classifier: Programming Language :: Python :: Free Threading :: 1 - Unstable
22
+ Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
23
23
  Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.7
24
25
  License-File: LICENSE
25
26
  Dynamic: author
26
27
  Dynamic: author-email
@@ -29,6 +30,7 @@ Dynamic: description
29
30
  Dynamic: home-page
30
31
  Dynamic: license
31
32
  Dynamic: license-file
33
+ Dynamic: requires-python
32
34
  Dynamic: summary
33
35
 
34
36
  bitarray: efficient arrays of booleans
@@ -90,9 +92,11 @@ Once you have installed the package, you may want to test it:
90
92
 
91
93
  $ python -c 'import bitarray; bitarray.test()'
92
94
  bitarray is installed in: /Users/ilan/bitarray/bitarray
93
- bitarray version: 3.8.2
94
- sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
95
+ bitarray version: 3.9.1
96
+ sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
95
97
  sys.prefix: /Users/ilan/miniforge
98
+ sys.abiflags: ''
99
+ sys._is_gil_enabled(): True
96
100
  pointer size: 64 bit
97
101
  sizeof(size_t): 8
98
102
  sizeof(bitarrayobject): 80
@@ -103,12 +107,12 @@ Once you have installed the package, you may want to test it:
103
107
  Py_DEBUG: 0
104
108
  DEBUG: 0
105
109
  .........................................................................
106
- .........................................................................
107
- ................................................................
110
+ ................................................s........................
111
+ ......s.........................................................
108
112
  ----------------------------------------------------------------------
109
- Ran 598 tests in 0.165s
113
+ Ran 632 tests in 0.191s
110
114
 
111
- OK
115
+ OK (skipped=2)
112
116
 
113
117
  The ``test()`` function is part of the API. It will return
114
118
  a ``unittest.runner.TextTestResult`` object, such that one can verify that
@@ -353,7 +357,7 @@ and can therefore be used as a dictionary key:
353
357
  Reference
354
358
  =========
355
359
 
356
- bitarray version: 3.8.2 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
360
+ bitarray version: 3.9.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
357
361
 
358
362
  In the following, ``item`` and ``value`` are usually a single bit -
359
363
  an integer 0 or 1.
@@ -422,13 +426,16 @@ bitarray methods:
422
426
 
423
427
  ``bytereverse(start=0, stop=<end of buffer>, /)``
424
428
  For each byte in byte-range(``start``, ``stop``) reverse bits in-place.
425
- The start and stop indices are given in terms of bytes (not bits).
429
+ The start and stop indices are given in terms of bytes (not bits) and
430
+ are interpreted like slice bounds and clipped to the buffer size.
426
431
  Also note that this method only changes the buffer; it does not change the
427
432
  bit-endianness of the bitarray object. Pad bits are left unchanged such
428
433
  that two consecutive calls will always leave the bitarray unchanged.
429
434
 
430
435
  New in version 2.2.5: optional start and stop arguments
431
436
 
437
+ New in version 3.9.1: clip arguments instead of raising ``IndexError``
438
+
432
439
 
433
440
  ``clear()``
434
441
  Remove all items from bitarray.
@@ -455,7 +462,7 @@ bitarray methods:
455
462
  New in version 2.9: add non-overlapping sub-bitarray count
456
463
 
457
464
 
458
- ``decode(code, /)`` -> iterator
465
+ ``decode(code, /)`` -> decodeiterator
459
466
  Given a prefix code (a dict mapping symbols to bitarrays, or ``decodetree``
460
467
  object), decode content of bitarray and return an iterator over
461
468
  corresponding symbols.
@@ -464,6 +471,8 @@ bitarray methods:
464
471
 
465
472
  New in version 3.0: returns iterator (equivalent to past ``.iterdecode()``)
466
473
 
474
+ New in version 3.9: returns public ``decodeiterator`` object
475
+
467
476
 
468
477
  ``encode(code, iterable, /)``
469
478
  Given a prefix code (a dict mapping symbols to bitarrays),
@@ -556,6 +565,19 @@ bitarray methods:
556
565
  Reverse all bits in bitarray (in-place).
557
566
 
558
567
 
568
+ ``rotate(k=1, /)``
569
+ Rotate bitarray in-place by ``k`` positions.
570
+ Positive ``k`` rotates right, negative ``k`` rotates left.
571
+
572
+ When bitarray ``a`` is not empty, rotating one step to the right is
573
+ equivalent to ``a.insert(0, a.pop())``, and rotating one step to the left
574
+ is equivalent to ``a.append(a.pop(0))``.
575
+ The same convention is used by the ``.rotate()`` method of
576
+ the ``collections.deque`` object.
577
+
578
+ New in version 3.9
579
+
580
+
559
581
  ``search(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> iterator
560
582
  Return iterator over indices where sub_bitarray is found, such that
561
583
  sub_bitarray is contained within ``[start:stop]``.
@@ -634,6 +656,25 @@ Data descriptors were added in version 2.6.
634
656
  bool indicating whether buffer is read-only
635
657
 
636
658
 
659
+ decodeiterator methods:
660
+ -----------------------
661
+
662
+ ``skipbits(n, /)`` -> bitarray
663
+ Skip over the next ``n`` bits and return them.
664
+ Raises ``ValueError`` if count is out of range.
665
+
666
+ New in version 3.9
667
+
668
+
669
+ decodeiterator data descriptors:
670
+ --------------------------------
671
+
672
+ ``index`` -> int
673
+ current bit position to be decoded by subsequent ``next``
674
+
675
+ New in version 3.9
676
+
677
+
637
678
  Other objects:
638
679
  --------------
639
680
 
@@ -911,9 +952,9 @@ This sub-module was added in version 1.2.
911
952
 
912
953
 
913
954
  ``sc_encode(bitarray, /)`` -> bytes
914
- Compress a sparse bitarray and return its binary representation.
915
- This representation is useful for efficiently storing sparse bitarrays.
916
- Use ``sc_decode()`` for decompressing (decoding).
955
+ Compress a bitarray using sparse encoding and return its binary
956
+ representation. This representation is useful for efficiently storing
957
+ sparse bitarrays. Use ``sc_decode()`` for decompressing (decoding).
917
958
 
918
959
  See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
919
960
 
@@ -57,9 +57,11 @@ Once you have installed the package, you may want to test it:
57
57
 
58
58
  $ python -c 'import bitarray; bitarray.test()'
59
59
  bitarray is installed in: /Users/ilan/bitarray/bitarray
60
- bitarray version: 3.8.2
61
- sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
60
+ bitarray version: 3.9.1
61
+ sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
62
62
  sys.prefix: /Users/ilan/miniforge
63
+ sys.abiflags: ''
64
+ sys._is_gil_enabled(): True
63
65
  pointer size: 64 bit
64
66
  sizeof(size_t): 8
65
67
  sizeof(bitarrayobject): 80
@@ -70,12 +72,12 @@ Once you have installed the package, you may want to test it:
70
72
  Py_DEBUG: 0
71
73
  DEBUG: 0
72
74
  .........................................................................
73
- .........................................................................
74
- ................................................................
75
+ ................................................s........................
76
+ ......s.........................................................
75
77
  ----------------------------------------------------------------------
76
- Ran 598 tests in 0.165s
78
+ Ran 632 tests in 0.191s
77
79
 
78
- OK
80
+ OK (skipped=2)
79
81
 
80
82
  The ``test()`` function is part of the API. It will return
81
83
  a ``unittest.runner.TextTestResult`` object, such that one can verify that
@@ -320,7 +322,7 @@ and can therefore be used as a dictionary key:
320
322
  Reference
321
323
  =========
322
324
 
323
- bitarray version: 3.8.2 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
325
+ bitarray version: 3.9.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
324
326
 
325
327
  In the following, ``item`` and ``value`` are usually a single bit -
326
328
  an integer 0 or 1.
@@ -389,13 +391,16 @@ bitarray methods:
389
391
 
390
392
  ``bytereverse(start=0, stop=<end of buffer>, /)``
391
393
  For each byte in byte-range(``start``, ``stop``) reverse bits in-place.
392
- The start and stop indices are given in terms of bytes (not bits).
394
+ The start and stop indices are given in terms of bytes (not bits) and
395
+ are interpreted like slice bounds and clipped to the buffer size.
393
396
  Also note that this method only changes the buffer; it does not change the
394
397
  bit-endianness of the bitarray object. Pad bits are left unchanged such
395
398
  that two consecutive calls will always leave the bitarray unchanged.
396
399
 
397
400
  New in version 2.2.5: optional start and stop arguments
398
401
 
402
+ New in version 3.9.1: clip arguments instead of raising ``IndexError``
403
+
399
404
 
400
405
  ``clear()``
401
406
  Remove all items from bitarray.
@@ -422,7 +427,7 @@ bitarray methods:
422
427
  New in version 2.9: add non-overlapping sub-bitarray count
423
428
 
424
429
 
425
- ``decode(code, /)`` -> iterator
430
+ ``decode(code, /)`` -> decodeiterator
426
431
  Given a prefix code (a dict mapping symbols to bitarrays, or ``decodetree``
427
432
  object), decode content of bitarray and return an iterator over
428
433
  corresponding symbols.
@@ -431,6 +436,8 @@ bitarray methods:
431
436
 
432
437
  New in version 3.0: returns iterator (equivalent to past ``.iterdecode()``)
433
438
 
439
+ New in version 3.9: returns public ``decodeiterator`` object
440
+
434
441
 
435
442
  ``encode(code, iterable, /)``
436
443
  Given a prefix code (a dict mapping symbols to bitarrays),
@@ -523,6 +530,19 @@ bitarray methods:
523
530
  Reverse all bits in bitarray (in-place).
524
531
 
525
532
 
533
+ ``rotate(k=1, /)``
534
+ Rotate bitarray in-place by ``k`` positions.
535
+ Positive ``k`` rotates right, negative ``k`` rotates left.
536
+
537
+ When bitarray ``a`` is not empty, rotating one step to the right is
538
+ equivalent to ``a.insert(0, a.pop())``, and rotating one step to the left
539
+ is equivalent to ``a.append(a.pop(0))``.
540
+ The same convention is used by the ``.rotate()`` method of
541
+ the ``collections.deque`` object.
542
+
543
+ New in version 3.9
544
+
545
+
526
546
  ``search(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> iterator
527
547
  Return iterator over indices where sub_bitarray is found, such that
528
548
  sub_bitarray is contained within ``[start:stop]``.
@@ -601,6 +621,25 @@ Data descriptors were added in version 2.6.
601
621
  bool indicating whether buffer is read-only
602
622
 
603
623
 
624
+ decodeiterator methods:
625
+ -----------------------
626
+
627
+ ``skipbits(n, /)`` -> bitarray
628
+ Skip over the next ``n`` bits and return them.
629
+ Raises ``ValueError`` if count is out of range.
630
+
631
+ New in version 3.9
632
+
633
+
634
+ decodeiterator data descriptors:
635
+ --------------------------------
636
+
637
+ ``index`` -> int
638
+ current bit position to be decoded by subsequent ``next``
639
+
640
+ New in version 3.9
641
+
642
+
604
643
  Other objects:
605
644
  --------------
606
645
 
@@ -878,9 +917,9 @@ This sub-module was added in version 1.2.
878
917
 
879
918
 
880
919
  ``sc_encode(bitarray, /)`` -> bytes
881
- Compress a sparse bitarray and return its binary representation.
882
- This representation is useful for efficiently storing sparse bitarrays.
883
- Use ``sc_decode()`` for decompressing (decoding).
920
+ Compress a bitarray using sparse encoding and return its binary
921
+ representation. This representation is useful for efficiently storing
922
+ sparse bitarrays. Use ``sc_decode()`` for decompressing (decoding).
884
923
 
885
924
  See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
886
925
 
@@ -12,11 +12,13 @@ Author: Ilan Schnell
12
12
  from collections import namedtuple
13
13
 
14
14
  from bitarray._bitarray import (
15
- bitarray, decodetree, bits2bytes, _bitarray_reconstructor,
16
- get_default_endian, _sysinfo, BITARRAY_VERSION as __version__
15
+ bitarray, decodetree, decodeiterator, _bitarray_reconstructor,
16
+ get_default_endian, bits2bytes, _sysinfo,
17
+ BITARRAY_VERSION as __version__
17
18
  )
18
19
 
19
- __all__ = ['bitarray', 'frozenbitarray', 'decodetree', 'bits2bytes']
20
+ __all__ = ['bitarray', 'frozenbitarray', 'decodetree', 'decodeiterator',
21
+ 'bits2bytes']
20
22
 
21
23
  BufferInfo = namedtuple('BufferInfo',
22
24
  ['address', 'nbytes', 'endian', 'padbits',
@@ -51,7 +53,7 @@ and may therefore be used as a dictionary key.
51
53
 
52
54
  append = bytereverse = clear = extend = encode = fill = __delitem__
53
55
  frombytes = fromfile = insert = invert = pack = pop = __delitem__
54
- remove = reverse = setall = sort = __setitem__ = __delitem__
56
+ remove = rotate = reverse = setall = sort = __setitem__ = __delitem__
55
57
  __iadd__ = __iand__ = __imul__ = __ior__ = __ixor__ = __delitem__
56
58
  __ilshift__ = __irshift__ = __delitem__
57
59
 
@@ -2,6 +2,7 @@
2
2
  #
3
3
  # This stub, as well as util.pyi, are tested with Python 3.10 and mypy 1.11.2
4
4
 
5
+ from abc import ABCMeta
5
6
  from collections.abc import Iterable, Iterator, Sequence
6
7
  from unittest.runner import TextTestResult
7
8
 
@@ -31,6 +32,12 @@ class decodetree:
31
32
  def todict(self) -> CodeDict: ...
32
33
 
33
34
 
35
+ class decodeiterator(Iterator, metaclass=ABCMeta):
36
+ @property
37
+ def index(self) -> int: ...
38
+ def skipbits(self, count: int = ...) -> bitarray: ...
39
+
40
+
34
41
  class bitarray:
35
42
  def __init__(self,
36
43
  initializer: Union[int, str, Iterable[int], None] = ...,
@@ -55,7 +62,7 @@ class bitarray:
55
62
 
56
63
  def encode(self, code: CodeDict, x: Iterable) -> None: ...
57
64
  def decode(self,
58
- code: Union[CodeDict, decodetree]) -> Iterator: ...
65
+ code: Union[CodeDict, decodetree]) -> decodeiterator: ...
59
66
 
60
67
  def extend(self, x: Union[str, Iterable[int]]) -> None: ...
61
68
  def fill(self) -> int: ...
@@ -85,6 +92,7 @@ class bitarray:
85
92
  def pack(self, b: BytesLike) -> None: ...
86
93
  def pop(self, i: int = ...) -> int: ...
87
94
  def remove(self, value: int) -> None: ...
95
+ def rotate(self, k: int = ...) -> None: ...
88
96
  def reverse(self) -> None: ...
89
97
 
90
98
  def setall(self, value: int) -> None: ...