bitstring 4.3.0__tar.gz → 4.4.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.
- {bitstring-4.3.0/bitstring.egg-info → bitstring-4.4.0}/PKG-INFO +16 -7
- {bitstring-4.3.0 → bitstring-4.4.0}/README.md +9 -4
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/__init__.py +17 -2
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/bitarray_.py +31 -6
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/bits.py +130 -174
- bitstring-4.3.0/bitstring/bitstore.py → bitstring-4.4.0/bitstring/bitstore_bitarray.py +129 -87
- bitstring-4.4.0/bitstring/bitstore_bitarray_helpers.py +80 -0
- bitstring-4.4.0/bitstring/bitstore_common_helpers.py +192 -0
- bitstring-4.4.0/bitstring/bitstore_tibs.py +454 -0
- bitstring-4.4.0/bitstring/bitstore_tibs_helpers.py +78 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/bitstream.py +22 -10
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/bitstring_options.py +19 -7
- bitstring-4.4.0/bitstring/helpers.py +40 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/methods.py +5 -3
- {bitstring-4.3.0 → bitstring-4.4.0/bitstring.egg-info}/PKG-INFO +16 -7
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring.egg-info/SOURCES.txt +6 -2
- bitstring-4.4.0/bitstring.egg-info/requires.txt +2 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/pyproject.toml +5 -2
- {bitstring-4.3.0 → bitstring-4.4.0}/release_notes.md +35 -1
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_benchmarks.py +4 -4
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_bitarray.py +45 -11
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_bits.py +3 -1
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_bitstore.py +13 -12
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_bitstream.py +21 -15
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_bitstring.py +8 -0
- bitstring-4.3.0/bitstring/bitstore_helpers.py +0 -270
- bitstring-4.3.0/bitstring.egg-info/requires.txt +0 -1
- {bitstring-4.3.0 → bitstring-4.4.0}/LICENSE +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/MANIFEST.in +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/__main__.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/array_.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/dtypes.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/exceptions.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/fp8.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/luts.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/mxfp.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/py.typed +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring/utils.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring.egg-info/dependency_links.txt +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/bitstring.egg-info/top_level.txt +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/setup.cfg +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/__init__.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/smalltestfile +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test.m1v +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_array.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_constbitstream.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_dtypes.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_fp8.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_mxfp.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0}/tests/test_scaled_dtypes.py +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: bitstring
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.4.0
|
|
4
4
|
Summary: Simple construction, analysis and modification of binary data.
|
|
5
5
|
Author-email: Scott Griffiths <dr.scottgriffiths@gmail.com>
|
|
6
|
+
License: MIT
|
|
6
7
|
Project-URL: homepage, https://github.com/scott-griffiths/bitstring
|
|
7
8
|
Project-URL: documentation, https://bitstring.readthedocs.io/
|
|
8
9
|
Keywords: binary,bitarray,bitvector,bitfield
|
|
@@ -16,12 +17,15 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
21
|
Classifier: License :: OSI Approved :: MIT License
|
|
20
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
23
|
Requires-Python: >=3.8
|
|
22
24
|
Description-Content-Type: text/markdown
|
|
23
25
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: bitarray<
|
|
26
|
+
Requires-Dist: bitarray<4.0,>=3.0.0
|
|
27
|
+
Requires-Dist: tibs<0.6,>=0.5.6
|
|
28
|
+
Dynamic: license-file
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
|
|
@@ -29,9 +33,6 @@ Requires-Dist: bitarray<3.1,>=3.0.0
|
|
|
29
33
|
|
|
30
34
|
**bitstring** is a Python library to help make the creation and analysis of all types of bit-level binary data as simple and efficient as possible. It has been actively maintained since 2006.
|
|
31
35
|
|
|
32
|
-
The library has has now been downloaded over 100 million times! ✨ [](https://www.pepy.tech/projects/bitstring) ✨
|
|
33
|
-
|
|
34
|
-
|
|
35
36
|
|
|
36
37
|
[](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)
|
|
37
38
|
[](https://bitstring.readthedocs.io/en/latest/)
|
|
@@ -46,6 +47,14 @@ The library has has now been downloaded over 100 million times!
|
|
|
46
47
|
> [!NOTE]
|
|
47
48
|
> To see what been added, improved or fixed, and also to see what's coming in the next version, see the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.md).
|
|
48
49
|
|
|
50
|
+
# News
|
|
51
|
+
|
|
52
|
+
I'm rewriting the core of bitstring in Rust, and have released that cut-down and streamlined interface as the [tibs](https://github.com/scott-griffiths/tibs) package. It's now in beta, and feedback is welcome. Just `pip install tibs` to try it out.
|
|
53
|
+
|
|
54
|
+
[](https://github.com/scott-griffiths/tibs)
|
|
55
|
+
|
|
56
|
+
A sleek Python library for your binary data
|
|
57
|
+
|
|
49
58
|
|
|
50
59
|
# Overview
|
|
51
60
|
|
|
@@ -131,4 +140,4 @@ Array('uint7', [45, 100, 15, 1])
|
|
|
131
140
|
```
|
|
132
141
|
|
|
133
142
|
|
|
134
|
-
<sub>Copyright (c) 2006 -
|
|
143
|
+
<sub>Copyright (c) 2006 - 2026 Scott Griffiths</sub>
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
**bitstring** is a Python library to help make the creation and analysis of all types of bit-level binary data as simple and efficient as possible. It has been actively maintained since 2006.
|
|
6
6
|
|
|
7
|
-
The library has has now been downloaded over 100 million times! ✨ [](https://www.pepy.tech/projects/bitstring) ✨
|
|
8
|
-
|
|
9
|
-
|
|
10
7
|
|
|
11
8
|
[](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)
|
|
12
9
|
[](https://bitstring.readthedocs.io/en/latest/)
|
|
@@ -21,6 +18,14 @@ The library has has now been downloaded over 100 million times!
|
|
|
21
18
|
> [!NOTE]
|
|
22
19
|
> To see what been added, improved or fixed, and also to see what's coming in the next version, see the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.md).
|
|
23
20
|
|
|
21
|
+
# News
|
|
22
|
+
|
|
23
|
+
I'm rewriting the core of bitstring in Rust, and have released that cut-down and streamlined interface as the [tibs](https://github.com/scott-griffiths/tibs) package. It's now in beta, and feedback is welcome. Just `pip install tibs` to try it out.
|
|
24
|
+
|
|
25
|
+
[](https://github.com/scott-griffiths/tibs)
|
|
26
|
+
|
|
27
|
+
A sleek Python library for your binary data
|
|
28
|
+
|
|
24
29
|
|
|
25
30
|
# Overview
|
|
26
31
|
|
|
@@ -106,4 +111,4 @@ Array('uint7', [45, 100, 15, 1])
|
|
|
106
111
|
```
|
|
107
112
|
|
|
108
113
|
|
|
109
|
-
<sub>Copyright (c) 2006 -
|
|
114
|
+
<sub>Copyright (c) 2006 - 2026 Scott Griffiths</sub>
|
|
@@ -55,11 +55,26 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
55
55
|
THE SOFTWARE.
|
|
56
56
|
"""
|
|
57
57
|
|
|
58
|
-
__version__ = "4.
|
|
58
|
+
__version__ = "4.4.0"
|
|
59
59
|
|
|
60
60
|
__author__ = "Scott Griffiths"
|
|
61
61
|
|
|
62
62
|
import sys
|
|
63
|
+
import os
|
|
64
|
+
import importlib
|
|
65
|
+
|
|
66
|
+
# New ability to use tibs for core operations instead of bitarray.
|
|
67
|
+
# Tibs is written in Rust and is still in beta. Use the environment variable
|
|
68
|
+
# BITSTRING_USE_RUST_CORE=1 before importing the module to turn it on.
|
|
69
|
+
_env_core = os.getenv('BITSTRING_USE_RUST_CORE', '').strip().lower()
|
|
70
|
+
_USE_RUST_CORE = _env_core in ('1', 'true', 'yes', 'on')
|
|
71
|
+
if _USE_RUST_CORE:
|
|
72
|
+
bitstore = importlib.import_module('bitstring.bitstore_tibs')
|
|
73
|
+
bitstore_helpers = importlib.import_module('bitstring.bitstore_tibs_helpers')
|
|
74
|
+
else:
|
|
75
|
+
bitstore = importlib.import_module('bitstring.bitstore_bitarray')
|
|
76
|
+
bitstore_helpers = importlib.import_module('bitstring.bitstore_bitarray_helpers')
|
|
77
|
+
bitstore_common_helpers = importlib.import_module('bitstring.bitstore_common_helpers')
|
|
63
78
|
|
|
64
79
|
from .bits import Bits
|
|
65
80
|
from .bitstring_options import Options
|
|
@@ -226,7 +241,7 @@ dtype_definitions = [
|
|
|
226
241
|
# String types
|
|
227
242
|
DtypeDefinition('hex', Bits._sethex, Bits._gethex, str, False, hex_bits2chars,
|
|
228
243
|
allowed_lengths=(0, 4, 8, ...), description="a hexadecimal string"),
|
|
229
|
-
DtypeDefinition('bin', Bits.
|
|
244
|
+
DtypeDefinition('bin', Bits._setbin, Bits._getbin, str, False, bin_bits2chars,
|
|
230
245
|
description="a binary string"),
|
|
231
246
|
DtypeDefinition('oct', Bits._setoct, Bits._getoct, str, False, oct_bits2chars,
|
|
232
247
|
allowed_lengths=(0, 3, 6, ...), description="an octal string"),
|
|
@@ -10,6 +10,9 @@ from bitstring.exceptions import CreationError, Error
|
|
|
10
10
|
from bitstring.bits import Bits, BitsType, TBits
|
|
11
11
|
|
|
12
12
|
import bitstring.dtypes
|
|
13
|
+
common_helpers = bitstring.bitstore_common_helpers
|
|
14
|
+
|
|
15
|
+
MutableBitStore = bitstring.bitstore.MutableBitStore
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
class BitArray(Bits):
|
|
@@ -112,14 +115,37 @@ class BitArray(Bits):
|
|
|
112
115
|
initialising using 'bytes' or 'filename'.
|
|
113
116
|
|
|
114
117
|
"""
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
pass
|
|
119
|
+
|
|
120
|
+
def __new__(cls: Type[TBits], auto: Optional[Union[BitsType, int]] = None, /, length: Optional[int] = None,
|
|
121
|
+
offset: Optional[int] = None, **kwargs) -> TBits:
|
|
122
|
+
x = super(Bits, cls).__new__(cls)
|
|
123
|
+
if auto is None and not kwargs:
|
|
124
|
+
# No initialiser so fill with zero bits up to length
|
|
125
|
+
if length is not None:
|
|
126
|
+
x._bitstore = MutableBitStore.from_zeros(length)
|
|
127
|
+
else:
|
|
128
|
+
x._bitstore = MutableBitStore()
|
|
129
|
+
return x
|
|
130
|
+
x._initialise(auto, length, offset, immutable=False, **kwargs)
|
|
131
|
+
return x
|
|
132
|
+
|
|
133
|
+
@classmethod
|
|
134
|
+
def fromstring(cls: TBits, s: str, /) -> TBits:
|
|
135
|
+
"""Create a new bitstring from a formatted string."""
|
|
136
|
+
x = super().__new__(cls)
|
|
137
|
+
b = common_helpers.str_to_bitstore(s)
|
|
138
|
+
x._bitstore = b._mutable_copy()
|
|
139
|
+
return x
|
|
118
140
|
|
|
119
141
|
def copy(self: TBits) -> TBits:
|
|
120
142
|
"""Return a copy of the bitstring."""
|
|
121
143
|
return self.__copy__()
|
|
122
144
|
|
|
145
|
+
def _invert_all(self) -> None:
|
|
146
|
+
"""Invert every bit."""
|
|
147
|
+
self._bitstore.invert()
|
|
148
|
+
|
|
123
149
|
def __setattr__(self, attribute, value) -> None:
|
|
124
150
|
try:
|
|
125
151
|
# First try the ordinary attribute setter
|
|
@@ -148,8 +174,7 @@ class BitArray(Bits):
|
|
|
148
174
|
def __copy__(self) -> BitArray:
|
|
149
175
|
"""Return a new copy of the BitArray."""
|
|
150
176
|
s_copy = BitArray()
|
|
151
|
-
s_copy._bitstore = self._bitstore.
|
|
152
|
-
assert s_copy._bitstore.immutable is False
|
|
177
|
+
s_copy._bitstore = self._bitstore._mutable_copy()
|
|
153
178
|
return s_copy
|
|
154
179
|
|
|
155
180
|
def _setitem_int(self, key: int, value: Union[BitsType, int]) -> None:
|
|
@@ -427,7 +452,7 @@ class BitArray(Bits):
|
|
|
427
452
|
"""
|
|
428
453
|
if pos is None:
|
|
429
454
|
# Set all bits to either 1 or 0
|
|
430
|
-
self.
|
|
455
|
+
self._bitstore.__setitem__(slice(None), bool(value))
|
|
431
456
|
return
|
|
432
457
|
if not isinstance(pos, abc.Iterable):
|
|
433
458
|
pos = (pos,)
|