bitarray 3.6.1__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.1 → bitarray-3.7.0}/PKG-INFO +50 -37
- {bitarray-3.6.1 → bitarray-3.7.0}/README.rst +49 -36
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/__init__.py +5 -1
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/__init__.pyi +14 -3
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/_bitarray.c +84 -77
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/_util.c +14 -15
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/bitarray.h +16 -1
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/test_bitarray.py +178 -158
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/test_util.py +133 -34
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/util.py +52 -12
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/util.pyi +4 -1
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray.egg-info/PKG-INFO +50 -37
- {bitarray-3.6.1 → bitarray-3.7.0}/LICENSE +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/py.typed +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/pythoncapi_compat.h +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray/test_281.pickle +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray.egg-info/SOURCES.txt +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray.egg-info/dependency_links.txt +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray.egg-info/not-zip-safe +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/bitarray.egg-info/top_level.txt +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/pyproject.toml +0 -0
- {bitarray-3.6.1 → bitarray-3.7.0}/setup.cfg +0 -0
- {bitarray-3.6.1 → 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
|
|
@@ -89,7 +89,7 @@ Once you have installed the package, you may want to test it:
|
|
|
89
89
|
|
|
90
90
|
$ python -c 'import bitarray; bitarray.test()'
|
|
91
91
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
92
|
-
bitarray version: 3.
|
|
92
|
+
bitarray version: 3.7.0
|
|
93
93
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
94
94
|
sys.prefix: /Users/ilan/miniforge
|
|
95
95
|
pointer size: 64 bit
|
|
@@ -98,12 +98,13 @@ Once you have installed the package, you may want to test it:
|
|
|
98
98
|
HAVE_BUILTIN_BSWAP64: 1
|
|
99
99
|
default bit-endianness: big
|
|
100
100
|
machine byte-order: little
|
|
101
|
+
Py_DEBUG: 0
|
|
101
102
|
DEBUG: 0
|
|
102
103
|
.........................................................................
|
|
103
104
|
.........................................................................
|
|
104
105
|
................................................................
|
|
105
106
|
----------------------------------------------------------------------
|
|
106
|
-
Ran
|
|
107
|
+
Ran 599 tests in 0.166s
|
|
107
108
|
|
|
108
109
|
OK
|
|
109
110
|
|
|
@@ -420,7 +421,7 @@ and can therefore be used as a dictionary key:
|
|
|
420
421
|
Reference
|
|
421
422
|
=========
|
|
422
423
|
|
|
423
|
-
bitarray version: 3.
|
|
424
|
+
bitarray version: 3.7.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
424
425
|
|
|
425
426
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
426
427
|
an integer 0 or 1.
|
|
@@ -459,34 +460,36 @@ bitarray methods:
|
|
|
459
460
|
-----------------
|
|
460
461
|
|
|
461
462
|
``all()`` -> bool
|
|
462
|
-
Return True when all bits in bitarray are
|
|
463
|
-
|
|
463
|
+
Return ``True`` when all bits in bitarray are 1.
|
|
464
|
+
``a.all()`` is a faster version of ``all(a)``.
|
|
464
465
|
|
|
465
466
|
|
|
466
467
|
``any()`` -> bool
|
|
467
|
-
Return True when any bit in bitarray is
|
|
468
|
-
|
|
468
|
+
Return ``True`` when any bit in bitarray is 1.
|
|
469
|
+
``a.any()`` is a faster version of ``any(a)``.
|
|
469
470
|
|
|
470
471
|
|
|
471
472
|
``append(item, /)``
|
|
472
473
|
Append ``item`` to the end of the bitarray.
|
|
473
474
|
|
|
474
475
|
|
|
475
|
-
``buffer_info()`` ->
|
|
476
|
-
Return
|
|
476
|
+
``buffer_info()`` -> BufferInfo
|
|
477
|
+
Return named tuple with following fields:
|
|
477
478
|
|
|
478
|
-
0. memory address of buffer
|
|
479
|
-
1. buffer size (in bytes)
|
|
480
|
-
2. bit-endianness as a
|
|
481
|
-
3. number of pad bits
|
|
482
|
-
4. allocated memory for
|
|
483
|
-
5. memory is read-only
|
|
484
|
-
6. buffer is imported
|
|
485
|
-
7. number of buffer exports
|
|
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
|
|
487
|
+
|
|
488
|
+
New in version 3.7: return named tuple
|
|
486
489
|
|
|
487
490
|
|
|
488
491
|
``bytereverse(start=0, stop=<end of buffer>, /)``
|
|
489
|
-
For each byte in byte-range(start
|
|
492
|
+
For each byte in byte-range(``start``, ``stop``) reverse bits in-place.
|
|
490
493
|
The start and stop indices are given in terms of bytes (not bits).
|
|
491
494
|
Also note that this method only changes the buffer; it does not change the
|
|
492
495
|
bit-endianness of the bitarray object. Pad bits are left unchanged such
|
|
@@ -496,13 +499,13 @@ bitarray methods:
|
|
|
496
499
|
|
|
497
500
|
|
|
498
501
|
``clear()``
|
|
499
|
-
Remove all items from
|
|
502
|
+
Remove all items from bitarray.
|
|
500
503
|
|
|
501
504
|
New in version 1.4
|
|
502
505
|
|
|
503
506
|
|
|
504
507
|
``copy()`` -> bitarray
|
|
505
|
-
Return
|
|
508
|
+
Return copy of bitarray (with same bit-endianness).
|
|
506
509
|
|
|
507
510
|
|
|
508
511
|
``count(value=1, start=0, stop=<end>, step=1, /)`` -> int
|
|
@@ -538,7 +541,7 @@ bitarray methods:
|
|
|
538
541
|
|
|
539
542
|
``extend(iterable, /)``
|
|
540
543
|
Append items from to the end of the bitarray.
|
|
541
|
-
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
|
|
542
545
|
bits (ignoring whitespace and underscore).
|
|
543
546
|
|
|
544
547
|
New in version 3.4: allow ``bytes`` object
|
|
@@ -578,7 +581,7 @@ bitarray methods:
|
|
|
578
581
|
``index(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
|
|
579
582
|
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
|
|
580
583
|
is found, such that sub_bitarray is contained within ``[start:stop]``.
|
|
581
|
-
Raises ``ValueError`` when
|
|
584
|
+
Raises ``ValueError`` when sub_bitarray is not present.
|
|
582
585
|
|
|
583
586
|
New in version 2.9: add optional keyword argument ``right``
|
|
584
587
|
|
|
@@ -589,7 +592,7 @@ bitarray methods:
|
|
|
589
592
|
|
|
590
593
|
``invert(index=<all bits>, /)``
|
|
591
594
|
Invert all bits in bitarray (in-place).
|
|
592
|
-
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``.
|
|
593
596
|
|
|
594
597
|
New in version 1.5.3: optional index argument
|
|
595
598
|
|
|
@@ -644,7 +647,7 @@ bitarray methods:
|
|
|
644
647
|
|
|
645
648
|
|
|
646
649
|
``to01(group=0, sep=' ')`` -> str
|
|
647
|
-
Return bitarray as Unicode string of
|
|
650
|
+
Return bitarray as (Unicode) string of ``0``s and ``1``s.
|
|
648
651
|
The bits are grouped into ``group`` bits (default is no grouping).
|
|
649
652
|
When grouped, the string ``sep`` is inserted between groups
|
|
650
653
|
of ``group`` characters, default is a space.
|
|
@@ -653,11 +656,11 @@ bitarray methods:
|
|
|
653
656
|
|
|
654
657
|
|
|
655
658
|
``tobytes()`` -> bytes
|
|
656
|
-
Return the bitarray buffer
|
|
659
|
+
Return the bitarray buffer (pad bits are set to zero).
|
|
657
660
|
|
|
658
661
|
|
|
659
662
|
``tofile(f, /)``
|
|
660
|
-
Write
|
|
663
|
+
Write bitarray buffer to file object ``f``.
|
|
661
664
|
|
|
662
665
|
|
|
663
666
|
``tolist()`` -> list
|
|
@@ -731,7 +734,7 @@ Functions defined in the `bitarray` module:
|
|
|
731
734
|
|
|
732
735
|
|
|
733
736
|
``test(verbosity=1)`` -> TextTestResult
|
|
734
|
-
Run self-test, and return unittest.runner.TextTestResult object.
|
|
737
|
+
Run self-test, and return ``unittest.runner.TextTestResult`` object.
|
|
735
738
|
|
|
736
739
|
|
|
737
740
|
Functions defined in `bitarray.util` module:
|
|
@@ -789,7 +792,7 @@ This sub-module was added in version 1.2.
|
|
|
789
792
|
New in version 3.3: ignore whitespace
|
|
790
793
|
|
|
791
794
|
|
|
792
|
-
``byteswap(a,
|
|
795
|
+
``byteswap(a, n=<buffer size>, /)``
|
|
793
796
|
Reverse every ``n`` consecutive bytes of ``a`` in-place.
|
|
794
797
|
By default, all bytes are reversed. Note that ``n`` is not limited to 2, 4
|
|
795
798
|
or 8, but can be any positive integer.
|
|
@@ -865,6 +868,15 @@ This sub-module was added in version 1.2.
|
|
|
865
868
|
New in version 2.5.0: allow bytes-like argument
|
|
866
869
|
|
|
867
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
|
+
|
|
868
880
|
``hex2ba(hexstr, /, endian=None)`` -> bitarray
|
|
869
881
|
Bitarray of hexadecimal representation. hexstr may contain any number
|
|
870
882
|
(including odd numbers) of hex digits (upper or lower case).
|
|
@@ -912,11 +924,9 @@ This sub-module was added in version 1.2.
|
|
|
912
924
|
|
|
913
925
|
|
|
914
926
|
``pprint(bitarray, /, stream=None, group=8, indent=4, width=80)``
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
Non-bitarray objects are printed by the standard library
|
|
919
|
-
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()``.
|
|
920
930
|
|
|
921
931
|
New in version 1.8
|
|
922
932
|
|
|
@@ -951,7 +961,7 @@ This sub-module was added in version 1.2.
|
|
|
951
961
|
New in version 3.5
|
|
952
962
|
|
|
953
963
|
|
|
954
|
-
``sc_decode(stream)`` -> bitarray
|
|
964
|
+
``sc_decode(stream, /)`` -> bitarray
|
|
955
965
|
Decompress binary stream (an integer iterator, or bytes-like object) of a
|
|
956
966
|
sparse compressed (``sc``) bitarray, and return the decoded bitarray.
|
|
957
967
|
This function consumes only one bitarray and leaves the remaining stream
|
|
@@ -994,12 +1004,15 @@ This sub-module was added in version 1.2.
|
|
|
994
1004
|
iteration is stopped as soon as one mismatch is found.
|
|
995
1005
|
|
|
996
1006
|
|
|
997
|
-
``sum_indices(a,
|
|
1007
|
+
``sum_indices(a, /, mode=1)`` -> int
|
|
998
1008
|
Return sum of indices of all active bits in bitarray ``a``.
|
|
999
1009
|
Equivalent to ``sum(i for i, v in enumerate(a) if v)``.
|
|
1010
|
+
``mode=2`` sums square of indices.
|
|
1000
1011
|
|
|
1001
1012
|
New in version 3.6
|
|
1002
1013
|
|
|
1014
|
+
New in version 3.7: add optional mode argument
|
|
1015
|
+
|
|
1003
1016
|
|
|
1004
1017
|
``urandom(n, /, endian=None)`` -> bitarray
|
|
1005
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
|
|
@@ -57,7 +57,7 @@ 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.
|
|
60
|
+
bitarray version: 3.7.0
|
|
61
61
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
62
62
|
sys.prefix: /Users/ilan/miniforge
|
|
63
63
|
pointer size: 64 bit
|
|
@@ -66,12 +66,13 @@ Once you have installed the package, you may want to test it:
|
|
|
66
66
|
HAVE_BUILTIN_BSWAP64: 1
|
|
67
67
|
default bit-endianness: big
|
|
68
68
|
machine byte-order: little
|
|
69
|
+
Py_DEBUG: 0
|
|
69
70
|
DEBUG: 0
|
|
70
71
|
.........................................................................
|
|
71
72
|
.........................................................................
|
|
72
73
|
................................................................
|
|
73
74
|
----------------------------------------------------------------------
|
|
74
|
-
Ran
|
|
75
|
+
Ran 599 tests in 0.166s
|
|
75
76
|
|
|
76
77
|
OK
|
|
77
78
|
|
|
@@ -388,7 +389,7 @@ and can therefore be used as a dictionary key:
|
|
|
388
389
|
Reference
|
|
389
390
|
=========
|
|
390
391
|
|
|
391
|
-
bitarray version: 3.
|
|
392
|
+
bitarray version: 3.7.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
392
393
|
|
|
393
394
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
394
395
|
an integer 0 or 1.
|
|
@@ -427,34 +428,36 @@ bitarray methods:
|
|
|
427
428
|
-----------------
|
|
428
429
|
|
|
429
430
|
``all()`` -> bool
|
|
430
|
-
Return True when all bits in bitarray are
|
|
431
|
-
|
|
431
|
+
Return ``True`` when all bits in bitarray are 1.
|
|
432
|
+
``a.all()`` is a faster version of ``all(a)``.
|
|
432
433
|
|
|
433
434
|
|
|
434
435
|
``any()`` -> bool
|
|
435
|
-
Return True when any bit in bitarray is
|
|
436
|
-
|
|
436
|
+
Return ``True`` when any bit in bitarray is 1.
|
|
437
|
+
``a.any()`` is a faster version of ``any(a)``.
|
|
437
438
|
|
|
438
439
|
|
|
439
440
|
``append(item, /)``
|
|
440
441
|
Append ``item`` to the end of the bitarray.
|
|
441
442
|
|
|
442
443
|
|
|
443
|
-
``buffer_info()`` ->
|
|
444
|
-
Return
|
|
444
|
+
``buffer_info()`` -> BufferInfo
|
|
445
|
+
Return named tuple with following fields:
|
|
445
446
|
|
|
446
|
-
0. memory address of buffer
|
|
447
|
-
1. buffer size (in bytes)
|
|
448
|
-
2. bit-endianness as a
|
|
449
|
-
3. number of pad bits
|
|
450
|
-
4. allocated memory for
|
|
451
|
-
5. memory is read-only
|
|
452
|
-
6. buffer is imported
|
|
453
|
-
7. number of buffer exports
|
|
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
|
|
455
|
+
|
|
456
|
+
New in version 3.7: return named tuple
|
|
454
457
|
|
|
455
458
|
|
|
456
459
|
``bytereverse(start=0, stop=<end of buffer>, /)``
|
|
457
|
-
For each byte in byte-range(start
|
|
460
|
+
For each byte in byte-range(``start``, ``stop``) reverse bits in-place.
|
|
458
461
|
The start and stop indices are given in terms of bytes (not bits).
|
|
459
462
|
Also note that this method only changes the buffer; it does not change the
|
|
460
463
|
bit-endianness of the bitarray object. Pad bits are left unchanged such
|
|
@@ -464,13 +467,13 @@ bitarray methods:
|
|
|
464
467
|
|
|
465
468
|
|
|
466
469
|
``clear()``
|
|
467
|
-
Remove all items from
|
|
470
|
+
Remove all items from bitarray.
|
|
468
471
|
|
|
469
472
|
New in version 1.4
|
|
470
473
|
|
|
471
474
|
|
|
472
475
|
``copy()`` -> bitarray
|
|
473
|
-
Return
|
|
476
|
+
Return copy of bitarray (with same bit-endianness).
|
|
474
477
|
|
|
475
478
|
|
|
476
479
|
``count(value=1, start=0, stop=<end>, step=1, /)`` -> int
|
|
@@ -506,7 +509,7 @@ bitarray methods:
|
|
|
506
509
|
|
|
507
510
|
``extend(iterable, /)``
|
|
508
511
|
Append items from to the end of the bitarray.
|
|
509
|
-
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
|
|
510
513
|
bits (ignoring whitespace and underscore).
|
|
511
514
|
|
|
512
515
|
New in version 3.4: allow ``bytes`` object
|
|
@@ -546,7 +549,7 @@ bitarray methods:
|
|
|
546
549
|
``index(sub_bitarray, start=0, stop=<end>, /, right=False)`` -> int
|
|
547
550
|
Return lowest (or rightmost when ``right=True``) index where sub_bitarray
|
|
548
551
|
is found, such that sub_bitarray is contained within ``[start:stop]``.
|
|
549
|
-
Raises ``ValueError`` when
|
|
552
|
+
Raises ``ValueError`` when sub_bitarray is not present.
|
|
550
553
|
|
|
551
554
|
New in version 2.9: add optional keyword argument ``right``
|
|
552
555
|
|
|
@@ -557,7 +560,7 @@ bitarray methods:
|
|
|
557
560
|
|
|
558
561
|
``invert(index=<all bits>, /)``
|
|
559
562
|
Invert all bits in bitarray (in-place).
|
|
560
|
-
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``.
|
|
561
564
|
|
|
562
565
|
New in version 1.5.3: optional index argument
|
|
563
566
|
|
|
@@ -612,7 +615,7 @@ bitarray methods:
|
|
|
612
615
|
|
|
613
616
|
|
|
614
617
|
``to01(group=0, sep=' ')`` -> str
|
|
615
|
-
Return bitarray as Unicode string of
|
|
618
|
+
Return bitarray as (Unicode) string of ``0``s and ``1``s.
|
|
616
619
|
The bits are grouped into ``group`` bits (default is no grouping).
|
|
617
620
|
When grouped, the string ``sep`` is inserted between groups
|
|
618
621
|
of ``group`` characters, default is a space.
|
|
@@ -621,11 +624,11 @@ bitarray methods:
|
|
|
621
624
|
|
|
622
625
|
|
|
623
626
|
``tobytes()`` -> bytes
|
|
624
|
-
Return the bitarray buffer
|
|
627
|
+
Return the bitarray buffer (pad bits are set to zero).
|
|
625
628
|
|
|
626
629
|
|
|
627
630
|
``tofile(f, /)``
|
|
628
|
-
Write
|
|
631
|
+
Write bitarray buffer to file object ``f``.
|
|
629
632
|
|
|
630
633
|
|
|
631
634
|
``tolist()`` -> list
|
|
@@ -699,7 +702,7 @@ Functions defined in the `bitarray` module:
|
|
|
699
702
|
|
|
700
703
|
|
|
701
704
|
``test(verbosity=1)`` -> TextTestResult
|
|
702
|
-
Run self-test, and return unittest.runner.TextTestResult object.
|
|
705
|
+
Run self-test, and return ``unittest.runner.TextTestResult`` object.
|
|
703
706
|
|
|
704
707
|
|
|
705
708
|
Functions defined in `bitarray.util` module:
|
|
@@ -757,7 +760,7 @@ This sub-module was added in version 1.2.
|
|
|
757
760
|
New in version 3.3: ignore whitespace
|
|
758
761
|
|
|
759
762
|
|
|
760
|
-
``byteswap(a,
|
|
763
|
+
``byteswap(a, n=<buffer size>, /)``
|
|
761
764
|
Reverse every ``n`` consecutive bytes of ``a`` in-place.
|
|
762
765
|
By default, all bytes are reversed. Note that ``n`` is not limited to 2, 4
|
|
763
766
|
or 8, but can be any positive integer.
|
|
@@ -833,6 +836,15 @@ This sub-module was added in version 1.2.
|
|
|
833
836
|
New in version 2.5.0: allow bytes-like argument
|
|
834
837
|
|
|
835
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
|
+
|
|
836
848
|
``hex2ba(hexstr, /, endian=None)`` -> bitarray
|
|
837
849
|
Bitarray of hexadecimal representation. hexstr may contain any number
|
|
838
850
|
(including odd numbers) of hex digits (upper or lower case).
|
|
@@ -880,11 +892,9 @@ This sub-module was added in version 1.2.
|
|
|
880
892
|
|
|
881
893
|
|
|
882
894
|
``pprint(bitarray, /, stream=None, group=8, indent=4, width=80)``
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
Non-bitarray objects are printed by the standard library
|
|
887
|
-
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()``.
|
|
888
898
|
|
|
889
899
|
New in version 1.8
|
|
890
900
|
|
|
@@ -919,7 +929,7 @@ This sub-module was added in version 1.2.
|
|
|
919
929
|
New in version 3.5
|
|
920
930
|
|
|
921
931
|
|
|
922
|
-
``sc_decode(stream)`` -> bitarray
|
|
932
|
+
``sc_decode(stream, /)`` -> bitarray
|
|
923
933
|
Decompress binary stream (an integer iterator, or bytes-like object) of a
|
|
924
934
|
sparse compressed (``sc``) bitarray, and return the decoded bitarray.
|
|
925
935
|
This function consumes only one bitarray and leaves the remaining stream
|
|
@@ -962,12 +972,15 @@ This sub-module was added in version 1.2.
|
|
|
962
972
|
iteration is stopped as soon as one mismatch is found.
|
|
963
973
|
|
|
964
974
|
|
|
965
|
-
``sum_indices(a,
|
|
975
|
+
``sum_indices(a, /, mode=1)`` -> int
|
|
966
976
|
Return sum of indices of all active bits in bitarray ``a``.
|
|
967
977
|
Equivalent to ``sum(i for i, v in enumerate(a) if v)``.
|
|
978
|
+
``mode=2`` sums square of indices.
|
|
968
979
|
|
|
969
980
|
New in version 3.6
|
|
970
981
|
|
|
982
|
+
New in version 3.7: add optional mode argument
|
|
983
|
+
|
|
971
984
|
|
|
972
985
|
``urandom(n, /, endian=None)`` -> bitarray
|
|
973
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,
|