bitarray 3.6.0__tar.gz → 3.7.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.
- {bitarray-3.6.0 → bitarray-3.7.0}/PKG-INFO +51 -45
- {bitarray-3.6.0 → bitarray-3.7.0}/README.rst +50 -44
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/__init__.py +5 -1
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/__init__.pyi +14 -3
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/_bitarray.c +84 -122
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/_util.c +90 -78
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/bitarray.h +31 -8
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/test_bitarray.py +178 -158
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/test_util.py +256 -104
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/util.py +97 -10
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/util.pyi +4 -1
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray.egg-info/PKG-INFO +51 -45
- {bitarray-3.6.0 → bitarray-3.7.0}/LICENSE +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/py.typed +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/pythoncapi_compat.h +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray/test_281.pickle +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray.egg-info/SOURCES.txt +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray.egg-info/dependency_links.txt +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray.egg-info/not-zip-safe +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/bitarray.egg-info/top_level.txt +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/pyproject.toml +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/setup.cfg +0 -0
- {bitarray-3.6.0 → bitarray-3.7.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bitarray
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.0
|
|
4
4
|
Summary: efficient arrays of booleans -- C extension
|
|
5
5
|
Home-page: https://github.com/ilanschnell/bitarray
|
|
6
6
|
Author: Ilan Schnell
|
|
@@ -59,7 +59,7 @@ Key features
|
|
|
59
59
|
* Immutable ``frozenbitarray`` objects which are hashable
|
|
60
60
|
* Sequential search
|
|
61
61
|
* Type hinting
|
|
62
|
-
* Extensive test suite with
|
|
62
|
+
* Extensive test suite with about 600 unittests
|
|
63
63
|
* Utility module ``bitarray.util``:
|
|
64
64
|
|
|
65
65
|
* conversion to and from hexadecimal strings
|
|
@@ -83,20 +83,13 @@ versions. Which means you can simply:
|
|
|
83
83
|
|
|
84
84
|
$ pip install bitarray
|
|
85
85
|
|
|
86
|
-
In addition, conda packages are available (both the default Anaconda
|
|
87
|
-
repository as well as conda-forge support bitarray):
|
|
88
|
-
|
|
89
|
-
.. code-block:: shell-session
|
|
90
|
-
|
|
91
|
-
$ conda install bitarray
|
|
92
|
-
|
|
93
86
|
Once you have installed the package, you may want to test it:
|
|
94
87
|
|
|
95
88
|
.. code-block:: shell-session
|
|
96
89
|
|
|
97
90
|
$ python -c 'import bitarray; bitarray.test()'
|
|
98
91
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
99
|
-
bitarray version: 3.
|
|
92
|
+
bitarray version: 3.7.0
|
|
100
93
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
101
94
|
sys.prefix: /Users/ilan/miniforge
|
|
102
95
|
pointer size: 64 bit
|
|
@@ -105,12 +98,13 @@ Once you have installed the package, you may want to test it:
|
|
|
105
98
|
HAVE_BUILTIN_BSWAP64: 1
|
|
106
99
|
default bit-endianness: big
|
|
107
100
|
machine byte-order: little
|
|
101
|
+
Py_DEBUG: 0
|
|
108
102
|
DEBUG: 0
|
|
109
103
|
.........................................................................
|
|
110
104
|
.........................................................................
|
|
111
105
|
................................................................
|
|
112
106
|
----------------------------------------------------------------------
|
|
113
|
-
Ran
|
|
107
|
+
Ran 599 tests in 0.166s
|
|
114
108
|
|
|
115
109
|
OK
|
|
116
110
|
|
|
@@ -427,7 +421,7 @@ and can therefore be used as a dictionary key:
|
|
|
427
421
|
Reference
|
|
428
422
|
=========
|
|
429
423
|
|
|
430
|
-
bitarray version: 3.
|
|
424
|
+
bitarray version: 3.7.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
431
425
|
|
|
432
426
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
433
427
|
an integer 0 or 1.
|
|
@@ -466,34 +460,36 @@ bitarray methods:
|
|
|
466
460
|
-----------------
|
|
467
461
|
|
|
468
462
|
``all()`` -> bool
|
|
469
|
-
Return True when all bits in bitarray are
|
|
470
|
-
|
|
463
|
+
Return ``True`` when all bits in bitarray are 1.
|
|
464
|
+
``a.all()`` is a faster version of ``all(a)``.
|
|
471
465
|
|
|
472
466
|
|
|
473
467
|
``any()`` -> bool
|
|
474
|
-
Return True when any bit in bitarray is
|
|
475
|
-
|
|
468
|
+
Return ``True`` when any bit in bitarray is 1.
|
|
469
|
+
``a.any()`` is a faster version of ``any(a)``.
|
|
476
470
|
|
|
477
471
|
|
|
478
472
|
``append(item, /)``
|
|
479
473
|
Append ``item`` to the end of the bitarray.
|
|
480
474
|
|
|
481
475
|
|
|
482
|
-
``buffer_info()`` ->
|
|
483
|
-
Return
|
|
476
|
+
``buffer_info()`` -> BufferInfo
|
|
477
|
+
Return named tuple with following fields:
|
|
478
|
+
|
|
479
|
+
0. ``address``: memory address of buffer
|
|
480
|
+
1. ``nbytes``: buffer size (in bytes)
|
|
481
|
+
2. ``endian``: bit-endianness as a string
|
|
482
|
+
3. ``padbits``: number of pad bits
|
|
483
|
+
4. ``alloc``: allocated memory for buffer (in bytes)
|
|
484
|
+
5. ``readonly``: memory is read-only (bool)
|
|
485
|
+
6. ``imported``: buffer is imported (bool)
|
|
486
|
+
7. ``exports``: number of buffer exports
|
|
484
487
|
|
|
485
|
-
|
|
486
|
-
1. buffer size (in bytes)
|
|
487
|
-
2. bit-endianness as a Unicode string
|
|
488
|
-
3. number of pad bits
|
|
489
|
-
4. allocated memory for the buffer (in bytes)
|
|
490
|
-
5. memory is read-only
|
|
491
|
-
6. buffer is imported
|
|
492
|
-
7. number of buffer exports
|
|
488
|
+
New in version 3.7: return named tuple
|
|
493
489
|
|
|
494
490
|
|
|
495
491
|
``bytereverse(start=0, stop=<end of buffer>, /)``
|
|
496
|
-
For each byte in byte-range(start
|
|
492
|
+
For each byte in byte-range(``start``, ``stop``) reverse bits in-place.
|
|
497
493
|
The start and stop indices are given in terms of bytes (not bits).
|
|
498
494
|
Also note that this method only changes the buffer; it does not change the
|
|
499
495
|
bit-endianness of the bitarray object. Pad bits are left unchanged such
|
|
@@ -503,13 +499,13 @@ bitarray methods:
|
|
|
503
499
|
|
|
504
500
|
|
|
505
501
|
``clear()``
|
|
506
|
-
Remove all items from
|
|
502
|
+
Remove all items from bitarray.
|
|
507
503
|
|
|
508
504
|
New in version 1.4
|
|
509
505
|
|
|
510
506
|
|
|
511
507
|
``copy()`` -> bitarray
|
|
512
|
-
Return
|
|
508
|
+
Return copy of bitarray (with same bit-endianness).
|
|
513
509
|
|
|
514
510
|
|
|
515
511
|
``count(value=1, start=0, stop=<end>, step=1, /)`` -> int
|
|
@@ -545,7 +541,7 @@ bitarray methods:
|
|
|
545
541
|
|
|
546
542
|
``extend(iterable, /)``
|
|
547
543
|
Append items from to the end of the bitarray.
|
|
548
|
-
If ``iterable`` is a Unicode string, each ``0`` and ``1`` are appended as
|
|
544
|
+
If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
|
|
549
545
|
bits (ignoring whitespace and underscore).
|
|
550
546
|
|
|
551
547
|
New in version 3.4: allow ``bytes`` object
|
|
@@ -585,7 +581,7 @@ bitarray methods:
|
|
|
585
581
|
``index(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
|
|
586
582
|
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
|
|
587
583
|
is found, such that sub_bitarray is contained within ``[start:stop]``.
|
|
588
|
-
Raises ``ValueError`` when
|
|
584
|
+
Raises ``ValueError`` when sub_bitarray is not present.
|
|
589
585
|
|
|
590
586
|
New in version 2.9: add optional keyword argument ``right``
|
|
591
587
|
|
|
@@ -596,7 +592,7 @@ bitarray methods:
|
|
|
596
592
|
|
|
597
593
|
``invert(index=<all bits>, /)``
|
|
598
594
|
Invert all bits in bitarray (in-place).
|
|
599
|
-
When the optional ``index`` is given, only invert the single bit at index
|
|
595
|
+
When the optional ``index`` is given, only invert the single bit at ``index``.
|
|
600
596
|
|
|
601
597
|
New in version 1.5.3: optional index argument
|
|
602
598
|
|
|
@@ -651,7 +647,7 @@ bitarray methods:
|
|
|
651
647
|
|
|
652
648
|
|
|
653
649
|
``to01(group=0, sep=' ')`` -> str
|
|
654
|
-
Return bitarray as Unicode string of
|
|
650
|
+
Return bitarray as (Unicode) string of ``0``s and ``1``s.
|
|
655
651
|
The bits are grouped into ``group`` bits (default is no grouping).
|
|
656
652
|
When grouped, the string ``sep`` is inserted between groups
|
|
657
653
|
of ``group`` characters, default is a space.
|
|
@@ -660,11 +656,11 @@ bitarray methods:
|
|
|
660
656
|
|
|
661
657
|
|
|
662
658
|
``tobytes()`` -> bytes
|
|
663
|
-
Return the bitarray buffer
|
|
659
|
+
Return the bitarray buffer (pad bits are set to zero).
|
|
664
660
|
|
|
665
661
|
|
|
666
662
|
``tofile(f, /)``
|
|
667
|
-
Write
|
|
663
|
+
Write bitarray buffer to file object ``f``.
|
|
668
664
|
|
|
669
665
|
|
|
670
666
|
``tolist()`` -> list
|
|
@@ -738,7 +734,7 @@ Functions defined in the `bitarray` module:
|
|
|
738
734
|
|
|
739
735
|
|
|
740
736
|
``test(verbosity=1)`` -> TextTestResult
|
|
741
|
-
Run self-test, and return unittest.runner.TextTestResult object.
|
|
737
|
+
Run self-test, and return ``unittest.runner.TextTestResult`` object.
|
|
742
738
|
|
|
743
739
|
|
|
744
740
|
Functions defined in `bitarray.util` module:
|
|
@@ -796,7 +792,7 @@ This sub-module was added in version 1.2.
|
|
|
796
792
|
New in version 3.3: ignore whitespace
|
|
797
793
|
|
|
798
794
|
|
|
799
|
-
``byteswap(a,
|
|
795
|
+
``byteswap(a, n=<buffer size>, /)``
|
|
800
796
|
Reverse every ``n`` consecutive bytes of ``a`` in-place.
|
|
801
797
|
By default, all bytes are reversed. Note that ``n`` is not limited to 2, 4
|
|
802
798
|
or 8, but can be any positive integer.
|
|
@@ -872,6 +868,15 @@ This sub-module was added in version 1.2.
|
|
|
872
868
|
New in version 2.5.0: allow bytes-like argument
|
|
873
869
|
|
|
874
870
|
|
|
871
|
+
``gen_primes(n, /, endian=None, odd=False)`` -> bitarray
|
|
872
|
+
Generate a bitarray of length ``n`` in which active indices are prime numbers.
|
|
873
|
+
By default (``odd=False``), active indices correspond to prime numbers directly.
|
|
874
|
+
When ``odd=True``, only odd prime numbers are represented in the resulting
|
|
875
|
+
bitarray ``a``, and ``a[i]`` corresponds to ``2*i+1`` being prime or not.
|
|
876
|
+
|
|
877
|
+
New in version 3.7
|
|
878
|
+
|
|
879
|
+
|
|
875
880
|
``hex2ba(hexstr, /, endian=None)`` -> bitarray
|
|
876
881
|
Bitarray of hexadecimal representation. hexstr may contain any number
|
|
877
882
|
(including odd numbers) of hex digits (upper or lower case).
|
|
@@ -919,11 +924,9 @@ This sub-module was added in version 1.2.
|
|
|
919
924
|
|
|
920
925
|
|
|
921
926
|
``pprint(bitarray, /, stream=None, group=8, indent=4, width=80)``
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
Non-bitarray objects are printed by the standard library
|
|
926
|
-
function ``pprint.pprint()``.
|
|
927
|
+
Pretty-print bitarray object to ``stream``, defaults is ``sys.stdout``.
|
|
928
|
+
By default, bits are grouped in bytes (8 bits), and 64 bits per line.
|
|
929
|
+
Non-bitarray objects are printed using ``pprint.pprint()``.
|
|
927
930
|
|
|
928
931
|
New in version 1.8
|
|
929
932
|
|
|
@@ -958,7 +961,7 @@ This sub-module was added in version 1.2.
|
|
|
958
961
|
New in version 3.5
|
|
959
962
|
|
|
960
963
|
|
|
961
|
-
``sc_decode(stream)`` -> bitarray
|
|
964
|
+
``sc_decode(stream, /)`` -> bitarray
|
|
962
965
|
Decompress binary stream (an integer iterator, or bytes-like object) of a
|
|
963
966
|
sparse compressed (``sc``) bitarray, and return the decoded bitarray.
|
|
964
967
|
This function consumes only one bitarray and leaves the remaining stream
|
|
@@ -1001,12 +1004,15 @@ This sub-module was added in version 1.2.
|
|
|
1001
1004
|
iteration is stopped as soon as one mismatch is found.
|
|
1002
1005
|
|
|
1003
1006
|
|
|
1004
|
-
``sum_indices(a,
|
|
1007
|
+
``sum_indices(a, /, mode=1)`` -> int
|
|
1005
1008
|
Return sum of indices of all active bits in bitarray ``a``.
|
|
1006
|
-
|
|
1009
|
+
Equivalent to ``sum(i for i, v in enumerate(a) if v)``.
|
|
1010
|
+
``mode=2`` sums square of indices.
|
|
1007
1011
|
|
|
1008
1012
|
New in version 3.6
|
|
1009
1013
|
|
|
1014
|
+
New in version 3.7: add optional mode argument
|
|
1015
|
+
|
|
1010
1016
|
|
|
1011
1017
|
``urandom(n, /, endian=None)`` -> bitarray
|
|
1012
1018
|
Return random bitarray of length ``n`` (uses ``os.urandom()``).
|
|
@@ -27,7 +27,7 @@ Key features
|
|
|
27
27
|
* Immutable ``frozenbitarray`` objects which are hashable
|
|
28
28
|
* Sequential search
|
|
29
29
|
* Type hinting
|
|
30
|
-
* Extensive test suite with
|
|
30
|
+
* Extensive test suite with about 600 unittests
|
|
31
31
|
* Utility module ``bitarray.util``:
|
|
32
32
|
|
|
33
33
|
* conversion to and from hexadecimal strings
|
|
@@ -51,20 +51,13 @@ versions. Which means you can simply:
|
|
|
51
51
|
|
|
52
52
|
$ pip install bitarray
|
|
53
53
|
|
|
54
|
-
In addition, conda packages are available (both the default Anaconda
|
|
55
|
-
repository as well as conda-forge support bitarray):
|
|
56
|
-
|
|
57
|
-
.. code-block:: shell-session
|
|
58
|
-
|
|
59
|
-
$ conda install bitarray
|
|
60
|
-
|
|
61
54
|
Once you have installed the package, you may want to test it:
|
|
62
55
|
|
|
63
56
|
.. code-block:: shell-session
|
|
64
57
|
|
|
65
58
|
$ python -c 'import bitarray; bitarray.test()'
|
|
66
59
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
67
|
-
bitarray version: 3.
|
|
60
|
+
bitarray version: 3.7.0
|
|
68
61
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
69
62
|
sys.prefix: /Users/ilan/miniforge
|
|
70
63
|
pointer size: 64 bit
|
|
@@ -73,12 +66,13 @@ Once you have installed the package, you may want to test it:
|
|
|
73
66
|
HAVE_BUILTIN_BSWAP64: 1
|
|
74
67
|
default bit-endianness: big
|
|
75
68
|
machine byte-order: little
|
|
69
|
+
Py_DEBUG: 0
|
|
76
70
|
DEBUG: 0
|
|
77
71
|
.........................................................................
|
|
78
72
|
.........................................................................
|
|
79
73
|
................................................................
|
|
80
74
|
----------------------------------------------------------------------
|
|
81
|
-
Ran
|
|
75
|
+
Ran 599 tests in 0.166s
|
|
82
76
|
|
|
83
77
|
OK
|
|
84
78
|
|
|
@@ -395,7 +389,7 @@ and can therefore be used as a dictionary key:
|
|
|
395
389
|
Reference
|
|
396
390
|
=========
|
|
397
391
|
|
|
398
|
-
bitarray version: 3.
|
|
392
|
+
bitarray version: 3.7.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
399
393
|
|
|
400
394
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
401
395
|
an integer 0 or 1.
|
|
@@ -434,34 +428,36 @@ bitarray methods:
|
|
|
434
428
|
-----------------
|
|
435
429
|
|
|
436
430
|
``all()`` -> bool
|
|
437
|
-
Return True when all bits in bitarray are
|
|
438
|
-
|
|
431
|
+
Return ``True`` when all bits in bitarray are 1.
|
|
432
|
+
``a.all()`` is a faster version of ``all(a)``.
|
|
439
433
|
|
|
440
434
|
|
|
441
435
|
``any()`` -> bool
|
|
442
|
-
Return True when any bit in bitarray is
|
|
443
|
-
|
|
436
|
+
Return ``True`` when any bit in bitarray is 1.
|
|
437
|
+
``a.any()`` is a faster version of ``any(a)``.
|
|
444
438
|
|
|
445
439
|
|
|
446
440
|
``append(item, /)``
|
|
447
441
|
Append ``item`` to the end of the bitarray.
|
|
448
442
|
|
|
449
443
|
|
|
450
|
-
``buffer_info()`` ->
|
|
451
|
-
Return
|
|
444
|
+
``buffer_info()`` -> BufferInfo
|
|
445
|
+
Return named tuple with following fields:
|
|
446
|
+
|
|
447
|
+
0. ``address``: memory address of buffer
|
|
448
|
+
1. ``nbytes``: buffer size (in bytes)
|
|
449
|
+
2. ``endian``: bit-endianness as a string
|
|
450
|
+
3. ``padbits``: number of pad bits
|
|
451
|
+
4. ``alloc``: allocated memory for buffer (in bytes)
|
|
452
|
+
5. ``readonly``: memory is read-only (bool)
|
|
453
|
+
6. ``imported``: buffer is imported (bool)
|
|
454
|
+
7. ``exports``: number of buffer exports
|
|
452
455
|
|
|
453
|
-
|
|
454
|
-
1. buffer size (in bytes)
|
|
455
|
-
2. bit-endianness as a Unicode string
|
|
456
|
-
3. number of pad bits
|
|
457
|
-
4. allocated memory for the buffer (in bytes)
|
|
458
|
-
5. memory is read-only
|
|
459
|
-
6. buffer is imported
|
|
460
|
-
7. number of buffer exports
|
|
456
|
+
New in version 3.7: return named tuple
|
|
461
457
|
|
|
462
458
|
|
|
463
459
|
``bytereverse(start=0, stop=<end of buffer>, /)``
|
|
464
|
-
For each byte in byte-range(start
|
|
460
|
+
For each byte in byte-range(``start``, ``stop``) reverse bits in-place.
|
|
465
461
|
The start and stop indices are given in terms of bytes (not bits).
|
|
466
462
|
Also note that this method only changes the buffer; it does not change the
|
|
467
463
|
bit-endianness of the bitarray object. Pad bits are left unchanged such
|
|
@@ -471,13 +467,13 @@ bitarray methods:
|
|
|
471
467
|
|
|
472
468
|
|
|
473
469
|
``clear()``
|
|
474
|
-
Remove all items from
|
|
470
|
+
Remove all items from bitarray.
|
|
475
471
|
|
|
476
472
|
New in version 1.4
|
|
477
473
|
|
|
478
474
|
|
|
479
475
|
``copy()`` -> bitarray
|
|
480
|
-
Return
|
|
476
|
+
Return copy of bitarray (with same bit-endianness).
|
|
481
477
|
|
|
482
478
|
|
|
483
479
|
``count(value=1, start=0, stop=<end>, step=1, /)`` -> int
|
|
@@ -513,7 +509,7 @@ bitarray methods:
|
|
|
513
509
|
|
|
514
510
|
``extend(iterable, /)``
|
|
515
511
|
Append items from to the end of the bitarray.
|
|
516
|
-
If ``iterable`` is a Unicode string, each ``0`` and ``1`` are appended as
|
|
512
|
+
If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
|
|
517
513
|
bits (ignoring whitespace and underscore).
|
|
518
514
|
|
|
519
515
|
New in version 3.4: allow ``bytes`` object
|
|
@@ -553,7 +549,7 @@ bitarray methods:
|
|
|
553
549
|
``index(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
|
|
554
550
|
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
|
|
555
551
|
is found, such that sub_bitarray is contained within ``[start:stop]``.
|
|
556
|
-
Raises ``ValueError`` when
|
|
552
|
+
Raises ``ValueError`` when sub_bitarray is not present.
|
|
557
553
|
|
|
558
554
|
New in version 2.9: add optional keyword argument ``right``
|
|
559
555
|
|
|
@@ -564,7 +560,7 @@ bitarray methods:
|
|
|
564
560
|
|
|
565
561
|
``invert(index=<all bits>, /)``
|
|
566
562
|
Invert all bits in bitarray (in-place).
|
|
567
|
-
When the optional ``index`` is given, only invert the single bit at index
|
|
563
|
+
When the optional ``index`` is given, only invert the single bit at ``index``.
|
|
568
564
|
|
|
569
565
|
New in version 1.5.3: optional index argument
|
|
570
566
|
|
|
@@ -619,7 +615,7 @@ bitarray methods:
|
|
|
619
615
|
|
|
620
616
|
|
|
621
617
|
``to01(group=0, sep=' ')`` -> str
|
|
622
|
-
Return bitarray as Unicode string of
|
|
618
|
+
Return bitarray as (Unicode) string of ``0``s and ``1``s.
|
|
623
619
|
The bits are grouped into ``group`` bits (default is no grouping).
|
|
624
620
|
When grouped, the string ``sep`` is inserted between groups
|
|
625
621
|
of ``group`` characters, default is a space.
|
|
@@ -628,11 +624,11 @@ bitarray methods:
|
|
|
628
624
|
|
|
629
625
|
|
|
630
626
|
``tobytes()`` -> bytes
|
|
631
|
-
Return the bitarray buffer
|
|
627
|
+
Return the bitarray buffer (pad bits are set to zero).
|
|
632
628
|
|
|
633
629
|
|
|
634
630
|
``tofile(f, /)``
|
|
635
|
-
Write
|
|
631
|
+
Write bitarray buffer to file object ``f``.
|
|
636
632
|
|
|
637
633
|
|
|
638
634
|
``tolist()`` -> list
|
|
@@ -706,7 +702,7 @@ Functions defined in the `bitarray` module:
|
|
|
706
702
|
|
|
707
703
|
|
|
708
704
|
``test(verbosity=1)`` -> TextTestResult
|
|
709
|
-
Run self-test, and return unittest.runner.TextTestResult object.
|
|
705
|
+
Run self-test, and return ``unittest.runner.TextTestResult`` object.
|
|
710
706
|
|
|
711
707
|
|
|
712
708
|
Functions defined in `bitarray.util` module:
|
|
@@ -764,7 +760,7 @@ This sub-module was added in version 1.2.
|
|
|
764
760
|
New in version 3.3: ignore whitespace
|
|
765
761
|
|
|
766
762
|
|
|
767
|
-
``byteswap(a,
|
|
763
|
+
``byteswap(a, n=<buffer size>, /)``
|
|
768
764
|
Reverse every ``n`` consecutive bytes of ``a`` in-place.
|
|
769
765
|
By default, all bytes are reversed. Note that ``n`` is not limited to 2, 4
|
|
770
766
|
or 8, but can be any positive integer.
|
|
@@ -840,6 +836,15 @@ This sub-module was added in version 1.2.
|
|
|
840
836
|
New in version 2.5.0: allow bytes-like argument
|
|
841
837
|
|
|
842
838
|
|
|
839
|
+
``gen_primes(n, /, endian=None, odd=False)`` -> bitarray
|
|
840
|
+
Generate a bitarray of length ``n`` in which active indices are prime numbers.
|
|
841
|
+
By default (``odd=False``), active indices correspond to prime numbers directly.
|
|
842
|
+
When ``odd=True``, only odd prime numbers are represented in the resulting
|
|
843
|
+
bitarray ``a``, and ``a[i]`` corresponds to ``2*i+1`` being prime or not.
|
|
844
|
+
|
|
845
|
+
New in version 3.7
|
|
846
|
+
|
|
847
|
+
|
|
843
848
|
``hex2ba(hexstr, /, endian=None)`` -> bitarray
|
|
844
849
|
Bitarray of hexadecimal representation. hexstr may contain any number
|
|
845
850
|
(including odd numbers) of hex digits (upper or lower case).
|
|
@@ -887,11 +892,9 @@ This sub-module was added in version 1.2.
|
|
|
887
892
|
|
|
888
893
|
|
|
889
894
|
``pprint(bitarray, /, stream=None, group=8, indent=4, width=80)``
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
Non-bitarray objects are printed by the standard library
|
|
894
|
-
function ``pprint.pprint()``.
|
|
895
|
+
Pretty-print bitarray object to ``stream``, defaults is ``sys.stdout``.
|
|
896
|
+
By default, bits are grouped in bytes (8 bits), and 64 bits per line.
|
|
897
|
+
Non-bitarray objects are printed using ``pprint.pprint()``.
|
|
895
898
|
|
|
896
899
|
New in version 1.8
|
|
897
900
|
|
|
@@ -926,7 +929,7 @@ This sub-module was added in version 1.2.
|
|
|
926
929
|
New in version 3.5
|
|
927
930
|
|
|
928
931
|
|
|
929
|
-
``sc_decode(stream)`` -> bitarray
|
|
932
|
+
``sc_decode(stream, /)`` -> bitarray
|
|
930
933
|
Decompress binary stream (an integer iterator, or bytes-like object) of a
|
|
931
934
|
sparse compressed (``sc``) bitarray, and return the decoded bitarray.
|
|
932
935
|
This function consumes only one bitarray and leaves the remaining stream
|
|
@@ -969,12 +972,15 @@ This sub-module was added in version 1.2.
|
|
|
969
972
|
iteration is stopped as soon as one mismatch is found.
|
|
970
973
|
|
|
971
974
|
|
|
972
|
-
``sum_indices(a,
|
|
975
|
+
``sum_indices(a, /, mode=1)`` -> int
|
|
973
976
|
Return sum of indices of all active bits in bitarray ``a``.
|
|
974
|
-
|
|
977
|
+
Equivalent to ``sum(i for i, v in enumerate(a) if v)``.
|
|
978
|
+
``mode=2`` sums square of indices.
|
|
975
979
|
|
|
976
980
|
New in version 3.6
|
|
977
981
|
|
|
982
|
+
New in version 3.7: add optional mode argument
|
|
983
|
+
|
|
978
984
|
|
|
979
985
|
``urandom(n, /, endian=None)`` -> bitarray
|
|
980
986
|
Return random bitarray of length ``n`` (uses ``os.urandom()``).
|
|
@@ -10,6 +10,7 @@ Please find a description of this package at:
|
|
|
10
10
|
Author: Ilan Schnell
|
|
11
11
|
"""
|
|
12
12
|
from __future__ import absolute_import
|
|
13
|
+
from collections import namedtuple
|
|
13
14
|
|
|
14
15
|
from bitarray._bitarray import (bitarray, decodetree, _sysinfo,
|
|
15
16
|
bits2bytes, _bitarray_reconstructor,
|
|
@@ -19,6 +20,9 @@ from bitarray._bitarray import (bitarray, decodetree, _sysinfo,
|
|
|
19
20
|
|
|
20
21
|
__all__ = ['bitarray', 'frozenbitarray', 'decodetree', 'bits2bytes']
|
|
21
22
|
|
|
23
|
+
BufferInfo = namedtuple('BufferInfo',
|
|
24
|
+
['address', 'nbytes', 'endian', 'padbits',
|
|
25
|
+
'alloc', 'readonly', 'imported', 'exports'])
|
|
22
26
|
|
|
23
27
|
class frozenbitarray(bitarray):
|
|
24
28
|
"""frozenbitarray(initializer=0, /, endian='big', buffer=None) -> \
|
|
@@ -57,7 +61,7 @@ and may therefore be used as a dictionary key.
|
|
|
57
61
|
def test(verbosity=1):
|
|
58
62
|
"""test(verbosity=1) -> TextTestResult
|
|
59
63
|
|
|
60
|
-
Run self-test, and return unittest.runner.TextTestResult object.
|
|
64
|
+
Run self-test, and return `unittest.runner.TextTestResult` object.
|
|
61
65
|
"""
|
|
62
66
|
from bitarray import test_bitarray
|
|
63
67
|
return test_bitarray.run(verbosity=verbosity)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
from collections.abc import Iterable, Iterator, Sequence
|
|
6
6
|
from unittest.runner import TextTestResult
|
|
7
7
|
|
|
8
|
-
from typing import Any, BinaryIO, Dict, Union, overload
|
|
8
|
+
from typing import Any, BinaryIO, Dict, Union, overload, NamedTuple
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
CodeDict = Dict[Any, bitarray]
|
|
@@ -13,6 +13,17 @@ CodeDict = Dict[Any, bitarray]
|
|
|
13
13
|
BytesLike = Union[bytes, bytearray]
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
class BufferInfo(NamedTuple):
|
|
17
|
+
address: int
|
|
18
|
+
nbytes: int
|
|
19
|
+
endian: str
|
|
20
|
+
padbits: int
|
|
21
|
+
alloc: int
|
|
22
|
+
readonly: bool
|
|
23
|
+
imported: bool
|
|
24
|
+
exports: int
|
|
25
|
+
|
|
26
|
+
|
|
16
27
|
class decodetree:
|
|
17
28
|
def __init__(self, code: CodeDict) -> None: ...
|
|
18
29
|
def complete(self) -> bool: ...
|
|
@@ -29,7 +40,7 @@ class bitarray:
|
|
|
29
40
|
def all(self) -> bool: ...
|
|
30
41
|
def any(self) -> bool: ...
|
|
31
42
|
def append(self, value: int) -> None: ...
|
|
32
|
-
def buffer_info(self) ->
|
|
43
|
+
def buffer_info(self) -> BufferInfo: ...
|
|
33
44
|
def bytereverse(self,
|
|
34
45
|
start: int = ...,
|
|
35
46
|
stop: int = ...) -> None: ...
|
|
@@ -149,7 +160,7 @@ def bits2bytes(n: int) -> int: ...
|
|
|
149
160
|
def get_default_endian() -> str: ...
|
|
150
161
|
def test(verbosity: int = ...) -> TextTestResult: ...
|
|
151
162
|
def _set_default_endian(endian: str) -> None: ...
|
|
152
|
-
def _sysinfo() ->
|
|
163
|
+
def _sysinfo(key: str) -> int: ...
|
|
153
164
|
def _bitarray_reconstructor(cls: type,
|
|
154
165
|
buffer: bytes,
|
|
155
166
|
endian: str,
|