bitarray 3.8.1__tar.gz → 3.9.0__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.1
3
+ Version: 3.9.0
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -11,7 +11,6 @@ Classifier: Intended Audience :: Developers
11
11
  Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: C
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.6
15
14
  Classifier: Programming Language :: Python :: 3.7
16
15
  Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
@@ -22,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.13
22
21
  Classifier: Programming Language :: Python :: 3.14
23
22
  Classifier: Programming Language :: Python :: Free Threading :: 1 - Unstable
24
23
  Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.7
25
25
  License-File: LICENSE
26
26
  Dynamic: author
27
27
  Dynamic: author-email
@@ -30,6 +30,7 @@ Dynamic: description
30
30
  Dynamic: home-page
31
31
  Dynamic: license
32
32
  Dynamic: license-file
33
+ Dynamic: requires-python
33
34
  Dynamic: summary
34
35
 
35
36
  bitarray: efficient arrays of booleans
@@ -91,8 +92,8 @@ Once you have installed the package, you may want to test it:
91
92
 
92
93
  $ python -c 'import bitarray; bitarray.test()'
93
94
  bitarray is installed in: /Users/ilan/bitarray/bitarray
94
- bitarray version: 3.8.1
95
- sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
95
+ bitarray version: 3.9.0
96
+ sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
96
97
  sys.prefix: /Users/ilan/miniforge
97
98
  pointer size: 64 bit
98
99
  sizeof(size_t): 8
@@ -104,12 +105,12 @@ Once you have installed the package, you may want to test it:
104
105
  Py_DEBUG: 0
105
106
  DEBUG: 0
106
107
  .........................................................................
107
- .........................................................................
108
- ................................................................
108
+ ................................................s........................
109
+ ......s.........................................................
109
110
  ----------------------------------------------------------------------
110
- Ran 598 tests in 0.165s
111
+ Ran 622 tests in 0.191s
111
112
 
112
- OK
113
+ OK (skipped=2)
113
114
 
114
115
  The ``test()`` function is part of the API. It will return
115
116
  a ``unittest.runner.TextTestResult`` object, such that one can verify that
@@ -354,7 +355,7 @@ and can therefore be used as a dictionary key:
354
355
  Reference
355
356
  =========
356
357
 
357
- bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
358
+ bitarray version: 3.9.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
358
359
 
359
360
  In the following, ``item`` and ``value`` are usually a single bit -
360
361
  an integer 0 or 1.
@@ -378,7 +379,7 @@ The bitarray object:
378
379
 
379
380
  ``endian``: Specifies the bit-endianness of the created bitarray object.
380
381
  Allowed values are ``big`` and ``little`` (the default is ``big``).
381
- The bit-endianness effects the buffer representation of the bitarray.
382
+ The bit-endianness affects the buffer representation of the bitarray.
382
383
 
383
384
  ``buffer``: Any object which exposes a buffer. When provided, ``initializer``
384
385
  cannot be present (or has to be ``None``). The imported buffer may be
@@ -456,7 +457,7 @@ bitarray methods:
456
457
  New in version 2.9: add non-overlapping sub-bitarray count
457
458
 
458
459
 
459
- ``decode(code, /)`` -> iterator
460
+ ``decode(code, /)`` -> decodeiterator
460
461
  Given a prefix code (a dict mapping symbols to bitarrays, or ``decodetree``
461
462
  object), decode content of bitarray and return an iterator over
462
463
  corresponding symbols.
@@ -465,6 +466,8 @@ bitarray methods:
465
466
 
466
467
  New in version 3.0: returns iterator (equivalent to past ``.iterdecode()``)
467
468
 
469
+ New in version 3.9: returns public ``decodeiterator`` object
470
+
468
471
 
469
472
  ``encode(code, iterable, /)``
470
473
  Given a prefix code (a dict mapping symbols to bitarrays),
@@ -473,7 +476,7 @@ bitarray methods:
473
476
 
474
477
 
475
478
  ``extend(iterable, /)``
476
- Append items from to the end of the bitarray.
479
+ Append items from iterable to the end of the bitarray.
477
480
  If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
478
481
  bits (ignoring whitespace and underscore).
479
482
 
@@ -504,7 +507,7 @@ bitarray methods:
504
507
 
505
508
  ``fromfile(f, n=-1, /)``
506
509
  Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
507
- other binary stream what supports a ``.read()`` method, e.g. ``io.BytesIO``).
510
+ other binary stream that supports a ``.read()`` method, e.g. ``io.BytesIO``).
508
511
  Each read byte will add eight bits to the bitarray. When ``n`` is omitted
509
512
  or negative, reads and extends all data until EOF.
510
513
  When ``n`` is non-negative but exceeds the available data, ``EOFError`` is
@@ -524,8 +527,9 @@ bitarray methods:
524
527
 
525
528
 
526
529
  ``invert(index=<all bits>, /)``
527
- Invert all bits in bitarray (in-place).
528
- When the optional ``index`` is given, only invert the single bit at ``index``.
530
+ Invert bits in-place. When ``index`` is omitted, invert all bits.
531
+ When ``index`` is an integer, invert the single bit at index.
532
+ When ``index`` is a slice, invert the selected bits.
529
533
 
530
534
  New in version 1.5.3: optional index argument
531
535
 
@@ -556,6 +560,19 @@ bitarray methods:
556
560
  Reverse all bits in bitarray (in-place).
557
561
 
558
562
 
563
+ ``rotate(k=1, /)``
564
+ Rotate bitarray in-place by ``k`` positions.
565
+ Positive ``k`` rotates right, negative ``k`` rotates left.
566
+
567
+ When bitarray is not empty, rotating one step to the right is
568
+ equivalent to ``a.insert(0, a.pop())``, and rotating one step to the left
569
+ is equivalent to ``a.append(a.pop(0))``.
570
+ The same convention is used by the ``.rotate()`` method of
571
+ the ``collections.deque`` object.
572
+
573
+ New in version 3.9
574
+
575
+
559
576
  ``search(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> iterator
560
577
  Return iterator over indices where sub_bitarray is found, such that
561
578
  sub_bitarray is contained within ``[start:stop]``.
@@ -608,7 +625,7 @@ bitarray methods:
608
625
 
609
626
  ``unpack(zero=b'\x00', one=b'\x01')`` -> bytes
610
627
  Return bytes that contain one byte for each bit in the bitarray,
611
- using specified mapping.
628
+ using the specified mapping.
612
629
 
613
630
 
614
631
  bitarray data descriptors:
@@ -634,6 +651,25 @@ Data descriptors were added in version 2.6.
634
651
  bool indicating whether buffer is read-only
635
652
 
636
653
 
654
+ decodeiterator methods:
655
+ -----------------------
656
+
657
+ ``skipbits(n, /)`` -> bitarray
658
+ Skip over the next ``n`` bits and return them.
659
+ Raises ``ValueError`` if count is out of range.
660
+
661
+ New in version 3.9
662
+
663
+
664
+ decodeiterator data descriptors:
665
+ --------------------------------
666
+
667
+ ``index`` -> int
668
+ current bit position to be decoded by subsequent ``next``
669
+
670
+ New in version 3.9
671
+
672
+
637
673
  Other objects:
638
674
  --------------
639
675
 
@@ -683,7 +719,8 @@ This sub-module was added in version 1.2.
683
719
  ``ba2base(n, bitarray, /, group=0, sep=' ')`` -> str
684
720
  Return a string containing the base ``n`` ASCII representation of
685
721
  the bitarray. Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
686
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.
722
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6
723
+ respectively.
687
724
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
688
725
  standard base 64 alphabet is used.
689
726
  When grouped, the string ``sep`` is inserted between groups
@@ -57,8 +57,8 @@ 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.1
61
- sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
60
+ bitarray version: 3.9.0
61
+ sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
62
62
  sys.prefix: /Users/ilan/miniforge
63
63
  pointer size: 64 bit
64
64
  sizeof(size_t): 8
@@ -70,12 +70,12 @@ Once you have installed the package, you may want to test it:
70
70
  Py_DEBUG: 0
71
71
  DEBUG: 0
72
72
  .........................................................................
73
- .........................................................................
74
- ................................................................
73
+ ................................................s........................
74
+ ......s.........................................................
75
75
  ----------------------------------------------------------------------
76
- Ran 598 tests in 0.165s
76
+ Ran 622 tests in 0.191s
77
77
 
78
- OK
78
+ OK (skipped=2)
79
79
 
80
80
  The ``test()`` function is part of the API. It will return
81
81
  a ``unittest.runner.TextTestResult`` object, such that one can verify that
@@ -320,7 +320,7 @@ and can therefore be used as a dictionary key:
320
320
  Reference
321
321
  =========
322
322
 
323
- bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
323
+ bitarray version: 3.9.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
324
324
 
325
325
  In the following, ``item`` and ``value`` are usually a single bit -
326
326
  an integer 0 or 1.
@@ -344,7 +344,7 @@ The bitarray object:
344
344
 
345
345
  ``endian``: Specifies the bit-endianness of the created bitarray object.
346
346
  Allowed values are ``big`` and ``little`` (the default is ``big``).
347
- The bit-endianness effects the buffer representation of the bitarray.
347
+ The bit-endianness affects the buffer representation of the bitarray.
348
348
 
349
349
  ``buffer``: Any object which exposes a buffer. When provided, ``initializer``
350
350
  cannot be present (or has to be ``None``). The imported buffer may be
@@ -422,7 +422,7 @@ bitarray methods:
422
422
  New in version 2.9: add non-overlapping sub-bitarray count
423
423
 
424
424
 
425
- ``decode(code, /)`` -> iterator
425
+ ``decode(code, /)`` -> decodeiterator
426
426
  Given a prefix code (a dict mapping symbols to bitarrays, or ``decodetree``
427
427
  object), decode content of bitarray and return an iterator over
428
428
  corresponding symbols.
@@ -431,6 +431,8 @@ bitarray methods:
431
431
 
432
432
  New in version 3.0: returns iterator (equivalent to past ``.iterdecode()``)
433
433
 
434
+ New in version 3.9: returns public ``decodeiterator`` object
435
+
434
436
 
435
437
  ``encode(code, iterable, /)``
436
438
  Given a prefix code (a dict mapping symbols to bitarrays),
@@ -439,7 +441,7 @@ bitarray methods:
439
441
 
440
442
 
441
443
  ``extend(iterable, /)``
442
- Append items from to the end of the bitarray.
444
+ Append items from iterable to the end of the bitarray.
443
445
  If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
444
446
  bits (ignoring whitespace and underscore).
445
447
 
@@ -470,7 +472,7 @@ bitarray methods:
470
472
 
471
473
  ``fromfile(f, n=-1, /)``
472
474
  Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
473
- other binary stream what supports a ``.read()`` method, e.g. ``io.BytesIO``).
475
+ other binary stream that supports a ``.read()`` method, e.g. ``io.BytesIO``).
474
476
  Each read byte will add eight bits to the bitarray. When ``n`` is omitted
475
477
  or negative, reads and extends all data until EOF.
476
478
  When ``n`` is non-negative but exceeds the available data, ``EOFError`` is
@@ -490,8 +492,9 @@ bitarray methods:
490
492
 
491
493
 
492
494
  ``invert(index=<all bits>, /)``
493
- Invert all bits in bitarray (in-place).
494
- When the optional ``index`` is given, only invert the single bit at ``index``.
495
+ Invert bits in-place. When ``index`` is omitted, invert all bits.
496
+ When ``index`` is an integer, invert the single bit at index.
497
+ When ``index`` is a slice, invert the selected bits.
495
498
 
496
499
  New in version 1.5.3: optional index argument
497
500
 
@@ -522,6 +525,19 @@ bitarray methods:
522
525
  Reverse all bits in bitarray (in-place).
523
526
 
524
527
 
528
+ ``rotate(k=1, /)``
529
+ Rotate bitarray in-place by ``k`` positions.
530
+ Positive ``k`` rotates right, negative ``k`` rotates left.
531
+
532
+ When bitarray is not empty, rotating one step to the right is
533
+ equivalent to ``a.insert(0, a.pop())``, and rotating one step to the left
534
+ is equivalent to ``a.append(a.pop(0))``.
535
+ The same convention is used by the ``.rotate()`` method of
536
+ the ``collections.deque`` object.
537
+
538
+ New in version 3.9
539
+
540
+
525
541
  ``search(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> iterator
526
542
  Return iterator over indices where sub_bitarray is found, such that
527
543
  sub_bitarray is contained within ``[start:stop]``.
@@ -574,7 +590,7 @@ bitarray methods:
574
590
 
575
591
  ``unpack(zero=b'\x00', one=b'\x01')`` -> bytes
576
592
  Return bytes that contain one byte for each bit in the bitarray,
577
- using specified mapping.
593
+ using the specified mapping.
578
594
 
579
595
 
580
596
  bitarray data descriptors:
@@ -600,6 +616,25 @@ Data descriptors were added in version 2.6.
600
616
  bool indicating whether buffer is read-only
601
617
 
602
618
 
619
+ decodeiterator methods:
620
+ -----------------------
621
+
622
+ ``skipbits(n, /)`` -> bitarray
623
+ Skip over the next ``n`` bits and return them.
624
+ Raises ``ValueError`` if count is out of range.
625
+
626
+ New in version 3.9
627
+
628
+
629
+ decodeiterator data descriptors:
630
+ --------------------------------
631
+
632
+ ``index`` -> int
633
+ current bit position to be decoded by subsequent ``next``
634
+
635
+ New in version 3.9
636
+
637
+
603
638
  Other objects:
604
639
  --------------
605
640
 
@@ -649,7 +684,8 @@ This sub-module was added in version 1.2.
649
684
  ``ba2base(n, bitarray, /, group=0, sep=' ')`` -> str
650
685
  Return a string containing the base ``n`` ASCII representation of
651
686
  the bitarray. Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
652
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.
687
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6
688
+ respectively.
653
689
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
654
690
  standard base 64 alphabet is used.
655
691
  When grouped, the string ``sep`` is inserted between groups
@@ -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: ...