bitstring 4.2.1__tar.gz → 4.2.3__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 (45) hide show
  1. {bitstring-4.2.1 → bitstring-4.2.3}/LICENSE +21 -21
  2. {bitstring-4.2.1 → bitstring-4.2.3}/MANIFEST.in +8 -8
  3. {bitstring-4.2.1/bitstring.egg-info → bitstring-4.2.3}/PKG-INFO +54 -68
  4. {bitstring-4.2.1 → bitstring-4.2.3}/README.md +109 -123
  5. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/__init__.py +337 -318
  6. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/__main__.py +50 -50
  7. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/array_.py +781 -775
  8. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/bitarray_.py +576 -577
  9. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/bits.py +1791 -1789
  10. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/bitstore.py +272 -254
  11. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/bitstore_helpers.py +270 -260
  12. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/bitstream.py +713 -713
  13. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/bitstring_options.py +95 -94
  14. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/dtypes.py +403 -400
  15. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/exceptions.py +23 -24
  16. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/fp8.py +97 -97
  17. bitstring-4.2.3/bitstring/luts.py +245 -0
  18. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/methods.py +95 -95
  19. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/mxfp.py +206 -200
  20. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/utils.py +238 -233
  21. {bitstring-4.2.1 → bitstring-4.2.3/bitstring.egg-info}/PKG-INFO +54 -68
  22. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring.egg-info/SOURCES.txt +2 -1
  23. {bitstring-4.2.1 → bitstring-4.2.3}/pyproject.toml +37 -37
  24. bitstring-4.2.1/release_notes.txt → bitstring-4.2.3/release_notes.md +1992 -1919
  25. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_array.py +928 -928
  26. bitstring-4.2.3/tests/test_benchmarks.py +72 -0
  27. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_bitarray.py +992 -992
  28. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_bits.py +970 -981
  29. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_bitstore.py +94 -94
  30. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_bitstream.py +4196 -4178
  31. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_bitstring.py +200 -200
  32. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_constbitstream.py +274 -265
  33. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_dtypes.py +154 -134
  34. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_fp8.py +335 -295
  35. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_mxfp.py +466 -441
  36. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test_scaled_dtypes.py +13 -13
  37. bitstring-4.2.1/bitstring/luts.py +0 -248
  38. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring/py.typed +0 -0
  39. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring.egg-info/dependency_links.txt +0 -0
  40. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring.egg-info/requires.txt +0 -0
  41. {bitstring-4.2.1 → bitstring-4.2.3}/bitstring.egg-info/top_level.txt +0 -0
  42. {bitstring-4.2.1 → bitstring-4.2.3}/setup.cfg +0 -0
  43. {bitstring-4.2.1 → bitstring-4.2.3}/tests/__init__.py +0 -0
  44. {bitstring-4.2.1 → bitstring-4.2.3}/tests/smalltestfile +0 -0
  45. {bitstring-4.2.1 → bitstring-4.2.3}/tests/test.m1v +0 -0
@@ -1,21 +1,21 @@
1
- The MIT License
2
-
3
- Copyright (c) 2006 Scott Griffiths (dr.scottgriffiths@gmail.com)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License
2
+
3
+ Copyright (c) 2006 Scott Griffiths (dr.scottgriffiths@gmail.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -1,8 +1,8 @@
1
- include tests/test.m1v
2
- include tests/smalltestfile
3
- include tests/__init__.py
4
- include release_notes.txt
5
- include README.md
6
- include bitstring/py.typed
7
- prune doc
8
- include LICENSE
1
+ include tests/test.m1v
2
+ include tests/smalltestfile
3
+ include tests/__init__.py
4
+ include release_notes.md
5
+ include README.md
6
+ include bitstring/py.typed
7
+ prune doc
8
+ include LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bitstring
3
- Version: 4.2.1
3
+ Version: 4.2.3
4
4
  Summary: Simple construction, analysis and modification of binary data.
5
5
  Author-email: Scott Griffiths <dr.scottgriffiths@gmail.com>
6
6
  Project-URL: homepage, https://github.com/scott-griffiths/bitstring
@@ -40,26 +40,13 @@ It has been actively maintained since 2006.
40
40
  [![Pepy Total Downlods](https://img.shields.io/pepy/dt/bitstring?logo=python&logoColor=white&labelColor=blue&color=blue)](https://www.pepy.tech/projects/bitstring)
41
41
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/bitstring?label=%40&labelColor=blue&color=blue)](https://pypistats.org/packages/bitstring)
42
42
 
43
-
44
- News
45
43
  ----
46
- **April 2024**: bitstring 4.2.1 released.
47
-
48
- New in version 4.2:
49
-
50
- * Dropped support for Python 3.7. Minimum version is now 3.8.
51
- * A new `Dtype` class can be optionally used to specify types.
52
- * The `bitstring.options` object is now the preferred method for changing module options.
53
- * New `fromstring` method as another way to create bitstrings from formatted strings.
54
- * More types can now be pretty printed.
55
- * A range of 8-bit, 6-bit and even 4-bit floating point formats added (beta):
56
- * Performance improvements.
57
44
 
58
- See the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.txt) for details. Please let me know if you encounter any problems.
45
+ > [!NOTE]
46
+ > 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).
59
47
 
60
48
 
61
- Overview
62
- --------
49
+ # Overview
63
50
 
64
51
  * Efficiently store and manipulate binary data in idiomatic Python.
65
52
  * Create bitstrings from hex, octal, binary, files, formatted strings, bytes, integers and floats of different endiannesses.
@@ -70,8 +57,8 @@ Overview
70
57
  * Rich API - chances are that whatever you want to do there's a simple and elegant way of doing it.
71
58
  * Open source software, released under the MIT licence.
72
59
 
73
- Documentation
74
- -------------
60
+ # Documentation
61
+
75
62
  Extensive documentation for the bitstring module is available.
76
63
  Some starting points are given below:
77
64
 
@@ -81,67 +68,66 @@ Some starting points are given below:
81
68
 
82
69
  There is also an introductory walkthrough notebook on [binder](https://mybinder.org/v2/gh/scott-griffiths/bitstring/main?labpath=doc%2Fwalkthrough.ipynb).
83
70
 
84
- Release Notes
85
- -------------
86
-
87
- 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.txt).
88
-
89
- Examples
90
- --------
71
+ # Examples
91
72
 
92
73
  ### Installation
93
-
94
- $ pip install bitstring
74
+ ```
75
+ $ pip install bitstring
76
+ ```
95
77
 
96
78
  ### Creation
97
-
98
- >>> from bitstring import Bits, BitArray, BitStream, pack
99
- >>> a = BitArray(bin='00101')
100
- >>> b = Bits(a_file_object)
101
- >>> c = BitArray('0xff, 0b101, 0o65, uint6=22')
102
- >>> d = pack('intle16, hex=a, 0b1', 100, a='0x34f')
103
- >>> e = pack('<16h', *range(16))
79
+ ```pycon
80
+ >>> from bitstring import Bits, BitArray, BitStream, pack
81
+ >>> a = BitArray(bin='00101')
82
+ >>> b = Bits(a_file_object)
83
+ >>> c = BitArray('0xff, 0b101, 0o65, uint6=22')
84
+ >>> d = pack('intle16, hex=a, 0b1', 100, a='0x34f')
85
+ >>> e = pack('<16h', *range(16))
86
+ ```
104
87
 
105
88
  ### Different interpretations, slicing and concatenation
106
-
107
- >>> a = BitArray('0x3348')
108
- >>> a.hex, a.bin, a.uint, a.float, a.bytes
109
- ('3348', '0011001101001000', 13128, 0.2275390625, b'3H')
110
- >>> a[10:3:-1].bin
111
- '0101100'
112
- >>> '0b100' + 3*a
113
- BitArray('0x866906690669, 0b000')
89
+ ```pycon
90
+ >>> a = BitArray('0x3348')
91
+ >>> a.hex, a.bin, a.uint, a.float, a.bytes
92
+ ('3348', '0011001101001000', 13128, 0.2275390625, b'3H')
93
+ >>> a[10:3:-1].bin
94
+ '0101100'
95
+ >>> '0b100' + 3*a
96
+ BitArray('0x866906690669, 0b000')
97
+ ```
114
98
 
115
99
  ### Reading data sequentially
116
-
117
- >>> b = BitStream('0x160120f')
118
- >>> b.read(12).hex
119
- '160'
120
- >>> b.pos = 0
121
- >>> b.read('uint12')
122
- 352
123
- >>> b.readlist('uint12, bin3')
124
- [288, '111']
100
+ ```pycon
101
+ >>> b = BitStream('0x160120f')
102
+ >>> b.read(12).hex
103
+ '160'
104
+ >>> b.pos = 0
105
+ >>> b.read('uint12')
106
+ 352
107
+ >>> b.readlist('uint12, bin3')
108
+ [288, '111']
109
+ ```
125
110
 
126
111
  ### Searching, inserting and deleting
127
-
128
- >>> c = BitArray('0b00010010010010001111') # c.hex == '0x1248f'
129
- >>> c.find('0x48')
130
- (8,)
131
- >>> c.replace('0b001', '0xabc')
132
- >>> c.insert('0b0000', pos=3)
133
- >>> del c[12:16]
112
+ ```pycon
113
+ >>> c = BitArray('0b00010010010010001111') # c.hex == '0x1248f'
114
+ >>> c.find('0x48')
115
+ (8,)
116
+ >>> c.replace('0b001', '0xabc')
117
+ >>> c.insert('0b0000', pos=3)
118
+ >>> del c[12:16]
119
+ ```
134
120
 
135
121
  ### Arrays of fixed-length formats
136
-
137
- >>> from bitstring import Array
138
- >>> a = Array('uint7', [9, 100, 3, 1])
139
- >>> a.data
140
- BitArray('0x1390181')
141
- >>> a[::2] *= 5
142
- >>> a
143
- Array('uint7', [45, 100, 15, 1])
144
-
122
+ ```pycon
123
+ >>> from bitstring import Array
124
+ >>> a = Array('uint7', [9, 100, 3, 1])
125
+ >>> a.data
126
+ BitArray('0x1390181')
127
+ >>> a[::2] *= 5
128
+ >>> a
129
+ Array('uint7', [45, 100, 15, 1])
130
+ ```
145
131
 
146
132
 
147
133
  <sub>Copyright (c) 2006 - 2024 Scott Griffiths</sub>
@@ -1,123 +1,109 @@
1
-
2
-
3
- ![bitstring](https://raw.githubusercontent.com/scott-griffiths/bitstring/main/doc/bitstring_logo_small.png "bitstring")
4
-
5
- **bitstring** is a Python module to help make the creation and analysis of all types of bit-level binary data as simple and efficient as possible.
6
-
7
- It has been actively maintained since 2006.
8
-
9
-
10
-
11
- [![CI badge](https://github.com/scott-griffiths/bitstring/actions/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)
12
- [![Docs](https://img.shields.io/readthedocs/bitstring?logo=readthedocs&logoColor=white)](https://bitstring.readthedocs.io/en/latest/)
13
- [![Codacy Badge](https://img.shields.io/codacy/grade/8869499b2eed44548fa1a5149dd451f4?logo=codacy)](https://app.codacy.com/gh/scott-griffiths/bitstring/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
14
- [![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/pypi/bitstring?logo=libraries.io&logoColor=white)](https://libraries.io/pypi/bitstring)
15
- &nbsp; &nbsp;
16
- [![Pepy Total Downlods](https://img.shields.io/pepy/dt/bitstring?logo=python&logoColor=white&labelColor=blue&color=blue)](https://www.pepy.tech/projects/bitstring)
17
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/bitstring?label=%40&labelColor=blue&color=blue)](https://pypistats.org/packages/bitstring)
18
-
19
-
20
- News
21
- ----
22
- **April 2024**: bitstring 4.2.1 released.
23
-
24
- New in version 4.2:
25
-
26
- * Dropped support for Python 3.7. Minimum version is now 3.8.
27
- * A new `Dtype` class can be optionally used to specify types.
28
- * The `bitstring.options` object is now the preferred method for changing module options.
29
- * New `fromstring` method as another way to create bitstrings from formatted strings.
30
- * More types can now be pretty printed.
31
- * A range of 8-bit, 6-bit and even 4-bit floating point formats added (beta):
32
- * Performance improvements.
33
-
34
- See the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.txt) for details. Please let me know if you encounter any problems.
35
-
36
-
37
- Overview
38
- --------
39
-
40
- * Efficiently store and manipulate binary data in idiomatic Python.
41
- * Create bitstrings from hex, octal, binary, files, formatted strings, bytes, integers and floats of different endiannesses.
42
- * Powerful binary packing and unpacking functions.
43
- * Bit-level slicing, joining, searching, replacing and more.
44
- * Create and manipulate arrays of fixed-length bitstrings.
45
- * Read from and interpret bitstrings as streams of binary data.
46
- * Rich API - chances are that whatever you want to do there's a simple and elegant way of doing it.
47
- * Open source software, released under the MIT licence.
48
-
49
- Documentation
50
- -------------
51
- Extensive documentation for the bitstring module is available.
52
- Some starting points are given below:
53
-
54
- * [Overview](https://bitstring.readthedocs.io/en/stable/index.html)
55
- * [Quick Reference](https://bitstring.readthedocs.io/en/stable/quick_reference.html)
56
- * [Full Reference](https://bitstring.readthedocs.io/en/stable/reference.html)
57
-
58
- There is also an introductory walkthrough notebook on [binder](https://mybinder.org/v2/gh/scott-griffiths/bitstring/main?labpath=doc%2Fwalkthrough.ipynb).
59
-
60
- Release Notes
61
- -------------
62
-
63
- 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.txt).
64
-
65
- Examples
66
- --------
67
-
68
- ### Installation
69
-
70
- $ pip install bitstring
71
-
72
- ### Creation
73
-
74
- >>> from bitstring import Bits, BitArray, BitStream, pack
75
- >>> a = BitArray(bin='00101')
76
- >>> b = Bits(a_file_object)
77
- >>> c = BitArray('0xff, 0b101, 0o65, uint6=22')
78
- >>> d = pack('intle16, hex=a, 0b1', 100, a='0x34f')
79
- >>> e = pack('<16h', *range(16))
80
-
81
- ### Different interpretations, slicing and concatenation
82
-
83
- >>> a = BitArray('0x3348')
84
- >>> a.hex, a.bin, a.uint, a.float, a.bytes
85
- ('3348', '0011001101001000', 13128, 0.2275390625, b'3H')
86
- >>> a[10:3:-1].bin
87
- '0101100'
88
- >>> '0b100' + 3*a
89
- BitArray('0x866906690669, 0b000')
90
-
91
- ### Reading data sequentially
92
-
93
- >>> b = BitStream('0x160120f')
94
- >>> b.read(12).hex
95
- '160'
96
- >>> b.pos = 0
97
- >>> b.read('uint12')
98
- 352
99
- >>> b.readlist('uint12, bin3')
100
- [288, '111']
101
-
102
- ### Searching, inserting and deleting
103
-
104
- >>> c = BitArray('0b00010010010010001111') # c.hex == '0x1248f'
105
- >>> c.find('0x48')
106
- (8,)
107
- >>> c.replace('0b001', '0xabc')
108
- >>> c.insert('0b0000', pos=3)
109
- >>> del c[12:16]
110
-
111
- ### Arrays of fixed-length formats
112
-
113
- >>> from bitstring import Array
114
- >>> a = Array('uint7', [9, 100, 3, 1])
115
- >>> a.data
116
- BitArray('0x1390181')
117
- >>> a[::2] *= 5
118
- >>> a
119
- Array('uint7', [45, 100, 15, 1])
120
-
121
-
122
-
123
- <sub>Copyright (c) 2006 - 2024 Scott Griffiths</sub>
1
+
2
+
3
+ ![bitstring](https://raw.githubusercontent.com/scott-griffiths/bitstring/main/doc/bitstring_logo_small.png "bitstring")
4
+
5
+ **bitstring** is a Python module to help make the creation and analysis of all types of bit-level binary data as simple and efficient as possible.
6
+
7
+ It has been actively maintained since 2006.
8
+
9
+
10
+
11
+ [![CI badge](https://github.com/scott-griffiths/bitstring/actions/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)
12
+ [![Docs](https://img.shields.io/readthedocs/bitstring?logo=readthedocs&logoColor=white)](https://bitstring.readthedocs.io/en/latest/)
13
+ [![Codacy Badge](https://img.shields.io/codacy/grade/8869499b2eed44548fa1a5149dd451f4?logo=codacy)](https://app.codacy.com/gh/scott-griffiths/bitstring/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
14
+ [![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/pypi/bitstring?logo=libraries.io&logoColor=white)](https://libraries.io/pypi/bitstring)
15
+ &nbsp; &nbsp;
16
+ [![Pepy Total Downlods](https://img.shields.io/pepy/dt/bitstring?logo=python&logoColor=white&labelColor=blue&color=blue)](https://www.pepy.tech/projects/bitstring)
17
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/bitstring?label=%40&labelColor=blue&color=blue)](https://pypistats.org/packages/bitstring)
18
+
19
+ ----
20
+
21
+ > [!NOTE]
22
+ > 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
+
24
+
25
+ # Overview
26
+
27
+ * Efficiently store and manipulate binary data in idiomatic Python.
28
+ * Create bitstrings from hex, octal, binary, files, formatted strings, bytes, integers and floats of different endiannesses.
29
+ * Powerful binary packing and unpacking functions.
30
+ * Bit-level slicing, joining, searching, replacing and more.
31
+ * Create and manipulate arrays of fixed-length bitstrings.
32
+ * Read from and interpret bitstrings as streams of binary data.
33
+ * Rich API - chances are that whatever you want to do there's a simple and elegant way of doing it.
34
+ * Open source software, released under the MIT licence.
35
+
36
+ # Documentation
37
+
38
+ Extensive documentation for the bitstring module is available.
39
+ Some starting points are given below:
40
+
41
+ * [Overview](https://bitstring.readthedocs.io/en/stable/index.html)
42
+ * [Quick Reference](https://bitstring.readthedocs.io/en/stable/quick_reference.html)
43
+ * [Full Reference](https://bitstring.readthedocs.io/en/stable/reference.html)
44
+
45
+ There is also an introductory walkthrough notebook on [binder](https://mybinder.org/v2/gh/scott-griffiths/bitstring/main?labpath=doc%2Fwalkthrough.ipynb).
46
+
47
+ # Examples
48
+
49
+ ### Installation
50
+ ```
51
+ $ pip install bitstring
52
+ ```
53
+
54
+ ### Creation
55
+ ```pycon
56
+ >>> from bitstring import Bits, BitArray, BitStream, pack
57
+ >>> a = BitArray(bin='00101')
58
+ >>> b = Bits(a_file_object)
59
+ >>> c = BitArray('0xff, 0b101, 0o65, uint6=22')
60
+ >>> d = pack('intle16, hex=a, 0b1', 100, a='0x34f')
61
+ >>> e = pack('<16h', *range(16))
62
+ ```
63
+
64
+ ### Different interpretations, slicing and concatenation
65
+ ```pycon
66
+ >>> a = BitArray('0x3348')
67
+ >>> a.hex, a.bin, a.uint, a.float, a.bytes
68
+ ('3348', '0011001101001000', 13128, 0.2275390625, b'3H')
69
+ >>> a[10:3:-1].bin
70
+ '0101100'
71
+ >>> '0b100' + 3*a
72
+ BitArray('0x866906690669, 0b000')
73
+ ```
74
+
75
+ ### Reading data sequentially
76
+ ```pycon
77
+ >>> b = BitStream('0x160120f')
78
+ >>> b.read(12).hex
79
+ '160'
80
+ >>> b.pos = 0
81
+ >>> b.read('uint12')
82
+ 352
83
+ >>> b.readlist('uint12, bin3')
84
+ [288, '111']
85
+ ```
86
+
87
+ ### Searching, inserting and deleting
88
+ ```pycon
89
+ >>> c = BitArray('0b00010010010010001111') # c.hex == '0x1248f'
90
+ >>> c.find('0x48')
91
+ (8,)
92
+ >>> c.replace('0b001', '0xabc')
93
+ >>> c.insert('0b0000', pos=3)
94
+ >>> del c[12:16]
95
+ ```
96
+
97
+ ### Arrays of fixed-length formats
98
+ ```pycon
99
+ >>> from bitstring import Array
100
+ >>> a = Array('uint7', [9, 100, 3, 1])
101
+ >>> a.data
102
+ BitArray('0x1390181')
103
+ >>> a[::2] *= 5
104
+ >>> a
105
+ Array('uint7', [45, 100, 15, 1])
106
+ ```
107
+
108
+
109
+ <sub>Copyright (c) 2006 - 2024 Scott Griffiths</sub>