bitstring 4.3.0__tar.gz → 4.4.0rc1__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.0rc1}/PKG-INFO +8 -4
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/README.md +1 -1
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/__init__.py +22 -2
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/bitarray_.py +31 -6
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/bits.py +130 -174
- bitstring-4.3.0/bitstring/bitstore.py → bitstring-4.4.0rc1/bitstring/bitstore_bitarray.py +129 -87
- bitstring-4.4.0rc1/bitstring/bitstore_bitarray_helpers.py +80 -0
- bitstring-4.4.0rc1/bitstring/bitstore_common_helpers.py +192 -0
- bitstring-4.4.0rc1/bitstring/bitstore_tibs.py +454 -0
- bitstring-4.4.0rc1/bitstring/bitstore_tibs_helpers.py +78 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/bitstream.py +22 -10
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/bitstring_options.py +19 -7
- bitstring-4.4.0rc1/bitstring/helpers.py +40 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/methods.py +5 -3
- {bitstring-4.3.0 → bitstring-4.4.0rc1/bitstring.egg-info}/PKG-INFO +8 -4
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring.egg-info/SOURCES.txt +6 -2
- bitstring-4.4.0rc1/bitstring.egg-info/requires.txt +2 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/pyproject.toml +5 -2
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/release_notes.md +35 -1
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_benchmarks.py +4 -4
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_bitarray.py +45 -11
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_bits.py +3 -1
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_bitstore.py +13 -12
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_bitstream.py +21 -15
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/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.0rc1}/LICENSE +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/MANIFEST.in +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/__main__.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/array_.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/dtypes.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/exceptions.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/fp8.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/luts.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/mxfp.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/py.typed +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring/utils.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring.egg-info/dependency_links.txt +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/bitstring.egg-info/top_level.txt +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/setup.cfg +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/__init__.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/smalltestfile +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test.m1v +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_array.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_constbitstream.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_dtypes.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_fp8.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/tests/test_mxfp.py +0 -0
- {bitstring-4.3.0 → bitstring-4.4.0rc1}/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.0rc1
|
|
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
|
|
|
@@ -131,4 +135,4 @@ Array('uint7', [45, 100, 15, 1])
|
|
|
131
135
|
```
|
|
132
136
|
|
|
133
137
|
|
|
134
|
-
<sub>Copyright (c) 2006 -
|
|
138
|
+
<sub>Copyright (c) 2006 - 2026 Scott Griffiths</sub>
|
|
@@ -55,11 +55,31 @@ 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
|
+
# Experimental ability to use tibs for core operations instead of bitarray.
|
|
67
|
+
# Tibs's core 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. The Rust core
|
|
69
|
+
# is not recommended for general use yet.
|
|
70
|
+
_env_core = os.getenv('BITSTRING_USE_RUST_CORE', '').strip().lower()
|
|
71
|
+
_USE_RUST_CORE = _env_core in ('1', 'true', 'yes', 'on')
|
|
72
|
+
if _USE_RUST_CORE:
|
|
73
|
+
try:
|
|
74
|
+
bitstore = importlib.import_module('bitstring.bitstore_tibs')
|
|
75
|
+
bitstore_helpers = importlib.import_module('bitstring.bitstore_tibs_helpers')
|
|
76
|
+
except Exception as e:
|
|
77
|
+
raise e
|
|
78
|
+
# raise ImportError("BITSTRING_USE_RUST_CORE is set, but the tibs library is unavailable.") from e
|
|
79
|
+
else:
|
|
80
|
+
bitstore = importlib.import_module('bitstring.bitstore_bitarray')
|
|
81
|
+
bitstore_helpers = importlib.import_module('bitstring.bitstore_bitarray_helpers')
|
|
82
|
+
bitstore_common_helpers = importlib.import_module('bitstring.bitstore_common_helpers')
|
|
63
83
|
|
|
64
84
|
from .bits import Bits
|
|
65
85
|
from .bitstring_options import Options
|
|
@@ -226,7 +246,7 @@ dtype_definitions = [
|
|
|
226
246
|
# String types
|
|
227
247
|
DtypeDefinition('hex', Bits._sethex, Bits._gethex, str, False, hex_bits2chars,
|
|
228
248
|
allowed_lengths=(0, 4, 8, ...), description="a hexadecimal string"),
|
|
229
|
-
DtypeDefinition('bin', Bits.
|
|
249
|
+
DtypeDefinition('bin', Bits._setbin, Bits._getbin, str, False, bin_bits2chars,
|
|
230
250
|
description="a binary string"),
|
|
231
251
|
DtypeDefinition('oct', Bits._setoct, Bits._getoct, str, False, oct_bits2chars,
|
|
232
252
|
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,)
|