bitarray 3.10.1__tar.gz → 3.12.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.
Files changed (26) hide show
  1. {bitarray-3.10.1 → bitarray-3.12.0}/PKG-INFO +147 -31
  2. {bitarray-3.10.1 → bitarray-3.12.0}/README.rst +145 -30
  3. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/__init__.py +1 -2
  4. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/__init__.pyi +1 -2
  5. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/_bitarray.c +66 -33
  6. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/_util.c +561 -177
  7. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/bitarray.h +9 -14
  8. bitarray-3.12.0/bitarray/bitfields.py +447 -0
  9. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/pythoncapi_compat.h +2 -2
  10. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/test_bitarray.py +77 -12
  11. bitarray-3.12.0/bitarray/test_bitfields.py +721 -0
  12. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/test_free_threading.py +6 -3
  13. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/test_util.py +471 -149
  14. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/util.py +113 -42
  15. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/util.pyi +4 -1
  16. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray.egg-info/PKG-INFO +147 -31
  17. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray.egg-info/SOURCES.txt +2 -0
  18. {bitarray-3.10.1 → bitarray-3.12.0}/setup.py +1 -0
  19. {bitarray-3.10.1 → bitarray-3.12.0}/LICENSE +0 -0
  20. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/py.typed +0 -0
  21. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray/test_281.pickle +0 -0
  22. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray.egg-info/dependency_links.txt +0 -0
  23. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray.egg-info/not-zip-safe +0 -0
  24. {bitarray-3.10.1 → bitarray-3.12.0}/bitarray.egg-info/top_level.txt +0 -0
  25. {bitarray-3.10.1 → bitarray-3.12.0}/pyproject.toml +0 -0
  26. {bitarray-3.10.1 → bitarray-3.12.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitarray
3
- Version: 3.10.1
3
+ Version: 3.12.0
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -19,6 +19,7 @@ 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 :: 3.15
22
23
  Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
23
24
  Classifier: Topic :: Utilities
24
25
  Requires-Python: >=3.7
@@ -54,16 +55,20 @@ Key features
54
55
  operations ``+``, ``*``, ``+=``, ``*=``, the ``in`` operator, ``len()``
55
56
  * Bitwise operations: ``~``, ``&``, ``|``, ``^``, ``<<``, ``>>`` (as well as
56
57
  their in-place versions ``&=``, ``|=``, ``^=``, ``<<=``, ``>>=``).
57
- * Free-threading support (for GIL disabled CPython 3.14 and later)
58
- * Fast methods for encoding and decoding variable bit length prefix codes.
59
- * Bitarray objects support the buffer protocol (both importing and
60
- exporting buffers).
61
- * Packing and unpacking to other binary data formats, e.g. ``numpy.ndarray``.
58
+ * `Free-threading support <https://github.com/ilanschnell/bitarray/blob/master/doc/free_threading.rst>`__
59
+ (for GIL-disabled CPython 3.14 and later)
60
+ * Fast methods for encoding and decoding variable-length prefix codes.
61
+ * Bitarray objects support the `buffer protocol <https://github.com/ilanschnell/bitarray/blob/master/doc/buffer.rst>`__
62
+ (both importing and exporting buffers).
63
+ * Efficient packing and unpacking for interoperability with byte-oriented
64
+ objects such as NumPy arrays.
62
65
  * Pickling and unpickling of bitarray objects.
63
66
  * Immutable ``frozenbitarray`` objects which are hashable
64
- * Sequential search
67
+ * Fast searching for bits and bit patterns
68
+ * ``bitfields`` sub-module for packing and unpacking fixed-width
69
+ `bit-field structures <https://github.com/ilanschnell/bitarray/blob/master/doc/bitfields.rst>`__
65
70
  * Type hinting
66
- * Extensive test suite with about 600 unittests
71
+ * Extensive test suite with over 700 unit tests
67
72
  * Utility module ``bitarray.util``:
68
73
 
69
74
  * conversion to and from hexadecimal strings
@@ -71,8 +76,9 @@ Key features
71
76
  * pretty printing
72
77
  * conversion to and from integers
73
78
  * creating Huffman codes
74
- * compression of sparse bitarrays
75
- * (de-) serialization
79
+ * `compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
80
+ * run-length encoding
81
+ * serialization and deserialization
76
82
  * various count functions
77
83
  * other helpful functions
78
84
 
@@ -94,7 +100,7 @@ Once you have installed the package, you may want to test it:
94
100
  $ python -c 'import bitarray; bitarray.test()'
95
101
  bitarray is installed in: /Users/ilan/bitarray/bitarray
96
102
  sys.prefix: /Users/ilan/miniforge
97
- bitarray version: 3.10.1
103
+ bitarray version: 3.12.0
98
104
  sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
99
105
  sys.abiflags: ''
100
106
  sys._is_gil_enabled(): True
@@ -111,7 +117,7 @@ Once you have installed the package, you may want to test it:
111
117
  ..........s.....................................s........................
112
118
  ......s.........................................................
113
119
  ----------------------------------------------------------------------
114
- Ran 640 tests in 0.192s
120
+ Ran 711 tests in 0.196s
115
121
 
116
122
  OK (skipped=4)
117
123
 
@@ -283,8 +289,8 @@ this topic, please read `buffer protocol <https://github.com/ilanschnell/bitarra
283
289
  to memory-map a file to a bitarray: `mmapped-file.py <https://github.com/ilanschnell/bitarray/blob/master/examples/mmapped-file.py>`__
284
290
 
285
291
 
286
- Variable bit length prefix codes
287
- --------------------------------
292
+ Variable-length prefix codes
293
+ ----------------------------
288
294
 
289
295
  The ``.encode()`` method takes a dictionary mapping symbols to bitarrays
290
296
  and an iterable, and extends the bitarray object with the encoded symbols
@@ -358,7 +364,7 @@ and can therefore be used as a dictionary key:
358
364
  Reference
359
365
  =========
360
366
 
361
- bitarray version: 3.10.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
367
+ bitarray version: 3.12.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
362
368
 
363
369
  In the following, ``item`` and ``value`` are usually a single bit -
364
370
  an integer 0 or 1.
@@ -394,7 +400,7 @@ The bitarray object:
394
400
 
395
401
 
396
402
  bitarray methods:
397
- -----------------
403
+ ^^^^^^^^^^^^^^^^^
398
404
 
399
405
  ``all()`` -> bool
400
406
  Return ``True`` when all bits in bitarray are 1.
@@ -490,9 +496,12 @@ bitarray methods:
490
496
  New in version 3.4: allow ``bytes`` object
491
497
 
492
498
 
493
- ``fill()`` -> int
499
+ ``fill(m=8, /)`` -> int
494
500
  Add zeros to the end of the bitarray, such that the length will be
495
- a multiple of 8, and return the number of bits added [0..7].
501
+ a multiple of the positive integer ``m``, and return the number of bits
502
+ added (in ``range(m)``).
503
+
504
+ New in version 3.12: add optional alignment argument
496
505
 
497
506
 
498
507
  ``find(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
@@ -638,10 +647,10 @@ bitarray methods:
638
647
  using the specified mapping.
639
648
 
640
649
 
641
- bitarray data descriptors:
642
- --------------------------
650
+ bitarray attributes:
651
+ ^^^^^^^^^^^^^^^^^^^^
643
652
 
644
- Data descriptors were added in version 2.6.
653
+ Attributes were added in version 2.6.
645
654
 
646
655
  ``endian`` -> str
647
656
  bit-endianness as Unicode string
@@ -662,7 +671,7 @@ Data descriptors were added in version 2.6.
662
671
 
663
672
 
664
673
  decodeiterator methods:
665
- -----------------------
674
+ ^^^^^^^^^^^^^^^^^^^^^^^
666
675
 
667
676
  ``skipbits(n, /)`` -> bitarray
668
677
  Skip over the next ``n`` bits and return them.
@@ -671,8 +680,8 @@ decodeiterator methods:
671
680
  New in version 3.9
672
681
 
673
682
 
674
- decodeiterator data descriptors:
675
- --------------------------------
683
+ decodeiterator attributes:
684
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
676
685
 
677
686
  ``index`` -> int
678
687
  current bit position to be decoded by subsequent ``next``
@@ -681,7 +690,7 @@ decodeiterator data descriptors:
681
690
 
682
691
 
683
692
  decodetree methods:
684
- -------------------
693
+ ^^^^^^^^^^^^^^^^^^^
685
694
 
686
695
  ``nodes()`` -> tuple
687
696
  Return tuple with number of:
@@ -783,7 +792,7 @@ This sub-module was added in version 1.2.
783
792
  Bitarray of base ``n`` ASCII representation.
784
793
  Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
785
794
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
786
- standard base 64 alphabet is used. Whitespace is ignored.
795
+ standard base 64 alphabet is used. ASCII whitespace is ignored.
787
796
 
788
797
  See also: `Bitarray representations <https://github.com/ilanschnell/bitarray/blob/master/doc/represent.rst>`__
789
798
 
@@ -891,7 +900,7 @@ This sub-module was added in version 1.2.
891
900
  ``hex2ba(hexstr, /, endian=None)`` -> bitarray
892
901
  Bitarray of hexadecimal representation. hexstr may contain any number
893
902
  (including odd numbers) of hex digits (upper or lower case).
894
- Whitespace is ignored.
903
+ ASCII whitespace is ignored.
895
904
 
896
905
  New in version 3.3: ignore whitespace
897
906
 
@@ -970,13 +979,34 @@ This sub-module was added in version 1.2.
970
979
  New in version 3.5
971
980
 
972
981
 
982
+ ``rl_decode(stream, /, endian=None)`` -> bitarray
983
+ Decode a run-length encoded bitarray from a binary stream (an integer
984
+ iterator, or bytes-like object), and return the decoded bitarray.
985
+ This function consumes only one bitarray and leaves the remaining stream
986
+ untouched. Use ``rl_encode()`` for encoding.
987
+
988
+ See also: `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
989
+
990
+ New in version 3.11
991
+
992
+
993
+ ``rl_encode(bitarray, /)`` -> bytes
994
+ Return the run-length encoded binary representation of a bitarray.
995
+ This representation may be useful for bitarrays with long runs of
996
+ identical bits. Use ``rl_decode()`` for decoding.
997
+
998
+ See also: `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
999
+
1000
+ New in version 3.11
1001
+
1002
+
973
1003
  ``sc_decode(stream, /)`` -> bitarray
974
1004
  Decompress binary stream (an integer iterator, or bytes-like object) of a
975
1005
  sparse compressed (``sc``) bitarray, and return the decoded bitarray.
976
1006
  This function consumes only one bitarray and leaves the remaining stream
977
1007
  untouched. Use ``sc_encode()`` for compressing (encoding).
978
1008
 
979
- See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
1009
+ See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
980
1010
 
981
1011
  New in version 2.7
982
1012
 
@@ -986,11 +1016,25 @@ This sub-module was added in version 1.2.
986
1016
  representation. This representation is useful for efficiently storing
987
1017
  sparse bitarrays. Use ``sc_decode()`` for decompressing (decoding).
988
1018
 
989
- See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
1019
+ See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
990
1020
 
991
1021
  New in version 2.7
992
1022
 
993
1023
 
1024
+ ``sc_stat(stream)`` -> dict
1025
+ Scan a stream produced by ``sc_encode()`` and return a dictionary containing
1026
+ its bit-endianness (``endian``), length (``nbits``), and the number of blocks
1027
+ of each type (``blocks``). ``blocks`` is a list such that ``blocks[i]`` is the
1028
+ number of blocks of type ``i``.
1029
+
1030
+ Like ``sc_decode()``, it consumes one encoded bitarray and leaves remaining
1031
+ input untouched.
1032
+
1033
+ See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
1034
+
1035
+ New in version 3.11
1036
+
1037
+
994
1038
  ``serialize(bitarray, /)`` -> bytes
995
1039
  Return a serialized representation of the bitarray, which may be passed to
996
1040
  ``deserialize()``. It efficiently represents the bitarray object (including
@@ -1034,7 +1078,7 @@ This sub-module was added in version 1.2.
1034
1078
  return the decoded bitarray. This function consumes only one bitarray and
1035
1079
  leaves the remaining stream untouched. Use ``vl_encode()`` for encoding.
1036
1080
 
1037
- See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__
1081
+ See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
1038
1082
 
1039
1083
  New in version 2.2
1040
1084
 
@@ -1044,7 +1088,7 @@ This sub-module was added in version 1.2.
1044
1088
  This representation is useful for efficiently storing small bitarray
1045
1089
  in a binary stream. Use ``vl_decode()`` for decoding.
1046
1090
 
1047
- See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__
1091
+ See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
1048
1092
 
1049
1093
  New in version 2.2
1050
1094
 
@@ -1062,3 +1106,75 @@ This sub-module was added in version 1.2.
1062
1106
  bit-endianness (``little`` or ``big``).
1063
1107
 
1064
1108
 
1109
+ The `bitarray.bitfields` module:
1110
+ --------------------------------
1111
+
1112
+ This sub-module was added in version 3.12.
1113
+ For a detailed description, see: `Bit-field structures <https://github.com/ilanschnell/bitarray/blob/master/doc/bitfields.rst>`__
1114
+
1115
+ ``Struct(format)`` -> compiled struct object
1116
+ Central class for packing and unpacking bit-level structures.
1117
+
1118
+
1119
+ ``calcsize(format)`` -> int
1120
+ Return the size (in bits) of the struct corresponding to the format string.
1121
+
1122
+
1123
+ ``compile(format)`` -> Struct
1124
+ Compile given format string and return a compiled format object that
1125
+ can be used to pack and/or unpack data multiple times.
1126
+
1127
+
1128
+ ``pack(format, v1, v2, ...)`` -> bitarray
1129
+ Return a bitarray containing the values v1, v2, ... packed according
1130
+ to the format string.
1131
+
1132
+
1133
+ ``pack_into(format, bitarray, offset, v1, v2, ...)`` -> None
1134
+ Pack the values v1, v2, ... into the writable bitarray starting at bit
1135
+ offset ``offset``. A negative offset counts from the end of bitarray.
1136
+
1137
+
1138
+ ``unpack(format, bitarray)`` -> tuple
1139
+ Return a tuple containing values unpacked according to the format string.
1140
+
1141
+
1142
+ ``unpack_from(format, bitarray, offset=0)`` -> tuple
1143
+ Unpack values from bitarray starting at bit offset ``offset``, and return a
1144
+ tuple. A negative offset counts from the end of bitarray.
1145
+
1146
+
1147
+ Struct methods:
1148
+ ^^^^^^^^^^^^^^^
1149
+
1150
+ ``format()`` -> str
1151
+ Return the canonical format string reconstructed from this compiled format.
1152
+
1153
+
1154
+ ``pack(v1, v2, ...)`` -> bitarray
1155
+ Return a bitarray containing the values v1, v2, ... packed according to this
1156
+ compiled format.
1157
+
1158
+
1159
+ ``pack_into(bitarray, offset, v1, v2, ...)`` -> None
1160
+ Pack the values v1, v2, ... into the writable bitarray starting at bit
1161
+ offset ``offset``. A negative offset counts from the end of bitarray.
1162
+
1163
+
1164
+ ``unpack(bitarray)`` -> tuple
1165
+ Return a tuple containing values unpacked according to this compiled format.
1166
+
1167
+
1168
+ ``unpack_from(bitarray, offset=0)`` -> tuple
1169
+ Unpack values from bitarray starting at bit offset ``offset``, and return a
1170
+ tuple. A negative offset counts from the end of bitarray.
1171
+
1172
+
1173
+ Struct attributes:
1174
+ ^^^^^^^^^^^^^^^^^^
1175
+
1176
+ ``width`` -> int
1177
+ Total number of bits in the compiled structure.
1178
+
1179
+ ``values`` -> int
1180
+ Number of values consumed by ``pack()`` and returned by ``unpack()``.
@@ -19,16 +19,20 @@ Key features
19
19
  operations ``+``, ``*``, ``+=``, ``*=``, the ``in`` operator, ``len()``
20
20
  * Bitwise operations: ``~``, ``&``, ``|``, ``^``, ``<<``, ``>>`` (as well as
21
21
  their in-place versions ``&=``, ``|=``, ``^=``, ``<<=``, ``>>=``).
22
- * Free-threading support (for GIL disabled CPython 3.14 and later)
23
- * Fast methods for encoding and decoding variable bit length prefix codes.
24
- * Bitarray objects support the buffer protocol (both importing and
25
- exporting buffers).
26
- * Packing and unpacking to other binary data formats, e.g. ``numpy.ndarray``.
22
+ * `Free-threading support <https://github.com/ilanschnell/bitarray/blob/master/doc/free_threading.rst>`__
23
+ (for GIL-disabled CPython 3.14 and later)
24
+ * Fast methods for encoding and decoding variable-length prefix codes.
25
+ * Bitarray objects support the `buffer protocol <https://github.com/ilanschnell/bitarray/blob/master/doc/buffer.rst>`__
26
+ (both importing and exporting buffers).
27
+ * Efficient packing and unpacking for interoperability with byte-oriented
28
+ objects such as NumPy arrays.
27
29
  * Pickling and unpickling of bitarray objects.
28
30
  * Immutable ``frozenbitarray`` objects which are hashable
29
- * Sequential search
31
+ * Fast searching for bits and bit patterns
32
+ * ``bitfields`` sub-module for packing and unpacking fixed-width
33
+ `bit-field structures <https://github.com/ilanschnell/bitarray/blob/master/doc/bitfields.rst>`__
30
34
  * Type hinting
31
- * Extensive test suite with about 600 unittests
35
+ * Extensive test suite with over 700 unit tests
32
36
  * Utility module ``bitarray.util``:
33
37
 
34
38
  * conversion to and from hexadecimal strings
@@ -36,8 +40,9 @@ Key features
36
40
  * pretty printing
37
41
  * conversion to and from integers
38
42
  * creating Huffman codes
39
- * compression of sparse bitarrays
40
- * (de-) serialization
43
+ * `compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
44
+ * run-length encoding
45
+ * serialization and deserialization
41
46
  * various count functions
42
47
  * other helpful functions
43
48
 
@@ -59,7 +64,7 @@ Once you have installed the package, you may want to test it:
59
64
  $ python -c 'import bitarray; bitarray.test()'
60
65
  bitarray is installed in: /Users/ilan/bitarray/bitarray
61
66
  sys.prefix: /Users/ilan/miniforge
62
- bitarray version: 3.10.1
67
+ bitarray version: 3.12.0
63
68
  sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
64
69
  sys.abiflags: ''
65
70
  sys._is_gil_enabled(): True
@@ -76,7 +81,7 @@ Once you have installed the package, you may want to test it:
76
81
  ..........s.....................................s........................
77
82
  ......s.........................................................
78
83
  ----------------------------------------------------------------------
79
- Ran 640 tests in 0.192s
84
+ Ran 711 tests in 0.196s
80
85
 
81
86
  OK (skipped=4)
82
87
 
@@ -248,8 +253,8 @@ this topic, please read `buffer protocol <https://github.com/ilanschnell/bitarra
248
253
  to memory-map a file to a bitarray: `mmapped-file.py <https://github.com/ilanschnell/bitarray/blob/master/examples/mmapped-file.py>`__
249
254
 
250
255
 
251
- Variable bit length prefix codes
252
- --------------------------------
256
+ Variable-length prefix codes
257
+ ----------------------------
253
258
 
254
259
  The ``.encode()`` method takes a dictionary mapping symbols to bitarrays
255
260
  and an iterable, and extends the bitarray object with the encoded symbols
@@ -323,7 +328,7 @@ and can therefore be used as a dictionary key:
323
328
  Reference
324
329
  =========
325
330
 
326
- bitarray version: 3.10.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
331
+ bitarray version: 3.12.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
327
332
 
328
333
  In the following, ``item`` and ``value`` are usually a single bit -
329
334
  an integer 0 or 1.
@@ -359,7 +364,7 @@ The bitarray object:
359
364
 
360
365
 
361
366
  bitarray methods:
362
- -----------------
367
+ ^^^^^^^^^^^^^^^^^
363
368
 
364
369
  ``all()`` -> bool
365
370
  Return ``True`` when all bits in bitarray are 1.
@@ -455,9 +460,12 @@ bitarray methods:
455
460
  New in version 3.4: allow ``bytes`` object
456
461
 
457
462
 
458
- ``fill()`` -> int
463
+ ``fill(m=8, /)`` -> int
459
464
  Add zeros to the end of the bitarray, such that the length will be
460
- a multiple of 8, and return the number of bits added [0..7].
465
+ a multiple of the positive integer ``m``, and return the number of bits
466
+ added (in ``range(m)``).
467
+
468
+ New in version 3.12: add optional alignment argument
461
469
 
462
470
 
463
471
  ``find(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
@@ -603,10 +611,10 @@ bitarray methods:
603
611
  using the specified mapping.
604
612
 
605
613
 
606
- bitarray data descriptors:
607
- --------------------------
614
+ bitarray attributes:
615
+ ^^^^^^^^^^^^^^^^^^^^
608
616
 
609
- Data descriptors were added in version 2.6.
617
+ Attributes were added in version 2.6.
610
618
 
611
619
  ``endian`` -> str
612
620
  bit-endianness as Unicode string
@@ -627,7 +635,7 @@ Data descriptors were added in version 2.6.
627
635
 
628
636
 
629
637
  decodeiterator methods:
630
- -----------------------
638
+ ^^^^^^^^^^^^^^^^^^^^^^^
631
639
 
632
640
  ``skipbits(n, /)`` -> bitarray
633
641
  Skip over the next ``n`` bits and return them.
@@ -636,8 +644,8 @@ decodeiterator methods:
636
644
  New in version 3.9
637
645
 
638
646
 
639
- decodeiterator data descriptors:
640
- --------------------------------
647
+ decodeiterator attributes:
648
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
641
649
 
642
650
  ``index`` -> int
643
651
  current bit position to be decoded by subsequent ``next``
@@ -646,7 +654,7 @@ decodeiterator data descriptors:
646
654
 
647
655
 
648
656
  decodetree methods:
649
- -------------------
657
+ ^^^^^^^^^^^^^^^^^^^
650
658
 
651
659
  ``nodes()`` -> tuple
652
660
  Return tuple with number of:
@@ -748,7 +756,7 @@ This sub-module was added in version 1.2.
748
756
  Bitarray of base ``n`` ASCII representation.
749
757
  Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
750
758
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
751
- standard base 64 alphabet is used. Whitespace is ignored.
759
+ standard base 64 alphabet is used. ASCII whitespace is ignored.
752
760
 
753
761
  See also: `Bitarray representations <https://github.com/ilanschnell/bitarray/blob/master/doc/represent.rst>`__
754
762
 
@@ -856,7 +864,7 @@ This sub-module was added in version 1.2.
856
864
  ``hex2ba(hexstr, /, endian=None)`` -> bitarray
857
865
  Bitarray of hexadecimal representation. hexstr may contain any number
858
866
  (including odd numbers) of hex digits (upper or lower case).
859
- Whitespace is ignored.
867
+ ASCII whitespace is ignored.
860
868
 
861
869
  New in version 3.3: ignore whitespace
862
870
 
@@ -935,13 +943,34 @@ This sub-module was added in version 1.2.
935
943
  New in version 3.5
936
944
 
937
945
 
946
+ ``rl_decode(stream, /, endian=None)`` -> bitarray
947
+ Decode a run-length encoded bitarray from a binary stream (an integer
948
+ iterator, or bytes-like object), and return the decoded bitarray.
949
+ This function consumes only one bitarray and leaves the remaining stream
950
+ untouched. Use ``rl_encode()`` for encoding.
951
+
952
+ See also: `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
953
+
954
+ New in version 3.11
955
+
956
+
957
+ ``rl_encode(bitarray, /)`` -> bytes
958
+ Return the run-length encoded binary representation of a bitarray.
959
+ This representation may be useful for bitarrays with long runs of
960
+ identical bits. Use ``rl_decode()`` for decoding.
961
+
962
+ See also: `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
963
+
964
+ New in version 3.11
965
+
966
+
938
967
  ``sc_decode(stream, /)`` -> bitarray
939
968
  Decompress binary stream (an integer iterator, or bytes-like object) of a
940
969
  sparse compressed (``sc``) bitarray, and return the decoded bitarray.
941
970
  This function consumes only one bitarray and leaves the remaining stream
942
971
  untouched. Use ``sc_encode()`` for compressing (encoding).
943
972
 
944
- See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
973
+ See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
945
974
 
946
975
  New in version 2.7
947
976
 
@@ -951,11 +980,25 @@ This sub-module was added in version 1.2.
951
980
  representation. This representation is useful for efficiently storing
952
981
  sparse bitarrays. Use ``sc_decode()`` for decompressing (decoding).
953
982
 
954
- See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
983
+ See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
955
984
 
956
985
  New in version 2.7
957
986
 
958
987
 
988
+ ``sc_stat(stream)`` -> dict
989
+ Scan a stream produced by ``sc_encode()`` and return a dictionary containing
990
+ its bit-endianness (``endian``), length (``nbits``), and the number of blocks
991
+ of each type (``blocks``). ``blocks`` is a list such that ``blocks[i]`` is the
992
+ number of blocks of type ``i``.
993
+
994
+ Like ``sc_decode()``, it consumes one encoded bitarray and leaves remaining
995
+ input untouched.
996
+
997
+ See also: `Compression of sparse bitarrays <https://github.com/ilanschnell/bitarray/blob/master/doc/sparse_compression.rst>`__
998
+
999
+ New in version 3.11
1000
+
1001
+
959
1002
  ``serialize(bitarray, /)`` -> bytes
960
1003
  Return a serialized representation of the bitarray, which may be passed to
961
1004
  ``deserialize()``. It efficiently represents the bitarray object (including
@@ -999,7 +1042,7 @@ This sub-module was added in version 1.2.
999
1042
  return the decoded bitarray. This function consumes only one bitarray and
1000
1043
  leaves the remaining stream untouched. Use ``vl_encode()`` for encoding.
1001
1044
 
1002
- See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__
1045
+ See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
1003
1046
 
1004
1047
  New in version 2.2
1005
1048
 
@@ -1009,7 +1052,7 @@ This sub-module was added in version 1.2.
1009
1052
  This representation is useful for efficiently storing small bitarray
1010
1053
  in a binary stream. Use ``vl_decode()`` for decoding.
1011
1054
 
1012
- See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__
1055
+ See also: `Variable length bitarray format <https://github.com/ilanschnell/bitarray/blob/master/doc/variable_length.rst>`__, `Comparison of bitarray codecs <https://github.com/ilanschnell/bitarray/blob/master/doc/codecs.rst>`__
1013
1056
 
1014
1057
  New in version 2.2
1015
1058
 
@@ -1027,3 +1070,75 @@ This sub-module was added in version 1.2.
1027
1070
  bit-endianness (``little`` or ``big``).
1028
1071
 
1029
1072
 
1073
+ The `bitarray.bitfields` module:
1074
+ --------------------------------
1075
+
1076
+ This sub-module was added in version 3.12.
1077
+ For a detailed description, see: `Bit-field structures <https://github.com/ilanschnell/bitarray/blob/master/doc/bitfields.rst>`__
1078
+
1079
+ ``Struct(format)`` -> compiled struct object
1080
+ Central class for packing and unpacking bit-level structures.
1081
+
1082
+
1083
+ ``calcsize(format)`` -> int
1084
+ Return the size (in bits) of the struct corresponding to the format string.
1085
+
1086
+
1087
+ ``compile(format)`` -> Struct
1088
+ Compile given format string and return a compiled format object that
1089
+ can be used to pack and/or unpack data multiple times.
1090
+
1091
+
1092
+ ``pack(format, v1, v2, ...)`` -> bitarray
1093
+ Return a bitarray containing the values v1, v2, ... packed according
1094
+ to the format string.
1095
+
1096
+
1097
+ ``pack_into(format, bitarray, offset, v1, v2, ...)`` -> None
1098
+ Pack the values v1, v2, ... into the writable bitarray starting at bit
1099
+ offset ``offset``. A negative offset counts from the end of bitarray.
1100
+
1101
+
1102
+ ``unpack(format, bitarray)`` -> tuple
1103
+ Return a tuple containing values unpacked according to the format string.
1104
+
1105
+
1106
+ ``unpack_from(format, bitarray, offset=0)`` -> tuple
1107
+ Unpack values from bitarray starting at bit offset ``offset``, and return a
1108
+ tuple. A negative offset counts from the end of bitarray.
1109
+
1110
+
1111
+ Struct methods:
1112
+ ^^^^^^^^^^^^^^^
1113
+
1114
+ ``format()`` -> str
1115
+ Return the canonical format string reconstructed from this compiled format.
1116
+
1117
+
1118
+ ``pack(v1, v2, ...)`` -> bitarray
1119
+ Return a bitarray containing the values v1, v2, ... packed according to this
1120
+ compiled format.
1121
+
1122
+
1123
+ ``pack_into(bitarray, offset, v1, v2, ...)`` -> None
1124
+ Pack the values v1, v2, ... into the writable bitarray starting at bit
1125
+ offset ``offset``. A negative offset counts from the end of bitarray.
1126
+
1127
+
1128
+ ``unpack(bitarray)`` -> tuple
1129
+ Return a tuple containing values unpacked according to this compiled format.
1130
+
1131
+
1132
+ ``unpack_from(bitarray, offset=0)`` -> tuple
1133
+ Unpack values from bitarray starting at bit offset ``offset``, and return a
1134
+ tuple. A negative offset counts from the end of bitarray.
1135
+
1136
+
1137
+ Struct attributes:
1138
+ ^^^^^^^^^^^^^^^^^^
1139
+
1140
+ ``width`` -> int
1141
+ Total number of bits in the compiled structure.
1142
+
1143
+ ``values`` -> int
1144
+ Number of values consumed by ``pack()`` and returned by ``unpack()``.
@@ -13,8 +13,7 @@ from collections import namedtuple
13
13
 
14
14
  from bitarray._bitarray import (
15
15
  bitarray, decodetree, decodeiterator, _bitarray_reconstructor,
16
- get_default_endian, bits2bytes, _sysinfo,
17
- BITARRAY_VERSION as __version__
16
+ get_default_endian, bits2bytes, BITARRAY_VERSION as __version__
18
17
  )
19
18
 
20
19
  __all__ = ['bitarray', 'frozenbitarray', 'decodetree', 'decodeiterator',
@@ -64,7 +64,7 @@ class bitarray:
64
64
  code: Union[CodeDict, decodetree]) -> decodeiterator: ...
65
65
 
66
66
  def extend(self, x: Union[str, Iterable[int]]) -> None: ...
67
- def fill(self) -> int: ...
67
+ def fill(self, m: int = ...) -> int: ...
68
68
  def find(self,
69
69
  sub_bitarray: Union[bitarray, int],
70
70
  start: int = ...,
@@ -169,7 +169,6 @@ __version__: str
169
169
  def bits2bytes(n: int) -> int: ...
170
170
  def get_default_endian() -> str: ...
171
171
  def test(verbosity: int = ...) -> TextTestResult: ...
172
- def _sysinfo(key: str) -> int: ...
173
172
  def _bitarray_reconstructor(cls: type,
174
173
  buffer: bytes,
175
174
  endian: str,