BinaryPacking 1.0.0__cp313-cp313-win_amd64.whl

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.
@@ -0,0 +1,187 @@
1
+ """Pack and unpack numeric values as binary data.
2
+
3
+ Fixed-width helpers use little-endian encoding by default and validate that
4
+ values fit the requested width. ``big`` reverses byte order; ``baremetal-*``
5
+ selects the same fixed width with the stated byte order; ``dense-*`` removes
6
+ redundant leading zero/sign-extension bytes and therefore produces variable
7
+ length output. Dense encodings are useful for compact storage but are not
8
+ interchangeable with fixed-width formats.
9
+
10
+ Examples:
11
+ >>> from Obex.Encoding import BinaryPacking
12
+ >>> BinaryPacking.PackInt32(258)
13
+ b'\\x02\\x01\\x00\\x00'
14
+ >>> BinaryPacking.UnPackInt32(b"\\x02\\x01\\x00\\x00")
15
+ 258
16
+ >>> BinaryPacking.PackUInt32(0x1234, "big")
17
+ b'\\x00\\x00\\x12\\x34'
18
+ >>> BinaryPacking.UnPackFloat32(BinaryPacking.PackFloat32(1.5))
19
+ 1.5
20
+ >>> BinaryPacking.UnPackBools(BinaryPacking.PackBools([True, False, True]))[:3]
21
+ [True, False, True]
22
+
23
+ Unpack functions require the exact fixed-width input size, except dense integer
24
+ formats, which accept non-empty variable-length encodings. Float helpers use
25
+ IEEE-754 binary formats. Boolean arrays store the first value in the least
26
+ significant bit for little-endian modes and in the most significant bit for
27
+ big-endian modes. Pointer helpers encode an unsigned 64-bit integer.
28
+ """
29
+
30
+ from typing import Literal
31
+
32
+ Endian = Literal[
33
+ "little",
34
+ "big",
35
+ "baremetal-little",
36
+ "baremetal-big",
37
+ "dense-little",
38
+ "dense-big",
39
+ ]
40
+
41
+ def ValidateEndian(Endian: str) -> tuple[str, bool]:
42
+ """Validate an endian option and return its byte order and dense-mode flag."""
43
+ ...
44
+
45
+ def RoundRatio(Numerator: int, Denominator: int) -> int:
46
+ """Round an integer ratio to nearest, resolving ties to an even result."""
47
+ ...
48
+
49
+ def ValidateFloatFormat(ExponentBits: int, FractionBits: int) -> int:
50
+ """Validate IEEE-like field widths and return their total bit count."""
51
+ ...
52
+
53
+ def PackInteger(Value: int, BitCount: int, Endian: Endian, Signed: bool) -> bytes:
54
+ """Encode an integer with an explicit width, signedness, and byte order."""
55
+ ...
56
+
57
+ def UnPackInteger(Value: bytes, BitCount: int, Endian: Endian, Signed: bool) -> int:
58
+ """Decode an integer encoded by PackInteger."""
59
+ ...
60
+
61
+ def FloatToBits(Value: float, ExponentBits: int, FractionBits: int) -> int:
62
+ """Encode a floating-point value as an integer IEEE-style bit pattern."""
63
+ ...
64
+
65
+ def BitsToFloat(Value: int, ExponentBits: int, FractionBits: int) -> float:
66
+ """Decode an integer IEEE-style bit pattern as a Python float."""
67
+ ...
68
+
69
+ def PackFloat(Value: float, ExponentBits: int, FractionBits: int, Endian: Endian) -> bytes:
70
+ """Pack a float using the selected exponent/fraction bit widths."""
71
+ ...
72
+
73
+ def UnPackFloat(Value: bytes, ExponentBits: int, FractionBits: int, Endian: Endian) -> float:
74
+ """Unpack a float using the selected exponent/fraction bit widths."""
75
+ ...
76
+
77
+ def PackInt8(Value: int, Endian: Endian = "little") -> bytes:
78
+ """Pack a signed 8-bit integer (range -128 through 127)."""
79
+ ...
80
+
81
+ def PackInt16(Value: int, Endian: Endian = "little") -> bytes:
82
+ """Pack a signed 16-bit integer (range -32768 through 32767)."""
83
+ ...
84
+
85
+ def PackInt32(Value: int, Endian: Endian = "little") -> bytes:
86
+ """Pack a signed 32-bit integer."""
87
+ ...
88
+
89
+ def PackInt64(Value: int, Endian: Endian = "little") -> bytes:
90
+ """Pack a signed 64-bit integer."""
91
+ ...
92
+
93
+ def PackUInt8(Value: int, Endian: Endian = "little") -> bytes:
94
+ """Pack an unsigned 8-bit integer (range 0 through 255)."""
95
+ ...
96
+
97
+ def PackUInt16(Value: int, Endian: Endian = "little") -> bytes:
98
+ """Pack an unsigned 16-bit integer."""
99
+ ...
100
+
101
+ def PackUInt32(Value: int, Endian: Endian = "little") -> bytes:
102
+ """Pack an unsigned 32-bit integer."""
103
+ ...
104
+
105
+ def PackUInt64(Value: int, Endian: Endian = "little") -> bytes:
106
+ """Pack an unsigned 64-bit integer."""
107
+ ...
108
+
109
+ def PackFloat16(Value: float, Endian: Endian = "little") -> bytes:
110
+ """Pack an IEEE-754 binary16 value into two bytes."""
111
+ ...
112
+
113
+ def PackFloat32(Value: float, Endian: Endian = "little") -> bytes:
114
+ """Pack an IEEE-754 binary32 value into four bytes."""
115
+ ...
116
+
117
+ def PackFloat64(Value: float, Endian: Endian = "little") -> bytes:
118
+ """Pack an IEEE-754 binary64 value into eight bytes."""
119
+ ...
120
+
121
+ def PackBool(Value: bool, Endian: Endian = "little") -> bytes:
122
+ """Pack one Boolean as a single byte containing zero or one."""
123
+ ...
124
+
125
+ def PackBools(Value: list[bool], Endian: Endian = "little") -> bytes:
126
+ """Pack Boolean values densely, eight values per output byte."""
127
+ ...
128
+
129
+ def PackPointer(Value: int, Endian: Endian = "little") -> bytes:
130
+ """Pack an unsigned 64-bit integer used to represent a pointer value."""
131
+ ...
132
+
133
+ def UnPackInt8(Value: bytes, Endian: Endian = "little") -> int:
134
+ """Unpack a signed 8-bit integer from exactly one byte."""
135
+ ...
136
+
137
+ def UnPackInt16(Value: bytes, Endian: Endian = "little") -> int:
138
+ """Unpack a signed 16-bit integer from exactly two bytes."""
139
+ ...
140
+
141
+ def UnPackInt32(Value: bytes, Endian: Endian = "little") -> int:
142
+ """Unpack a signed 32-bit integer from exactly four bytes."""
143
+ ...
144
+
145
+ def UnPackInt64(Value: bytes, Endian: Endian = "little") -> int:
146
+ """Unpack a signed 64-bit integer from exactly eight bytes."""
147
+ ...
148
+
149
+ def UnPackUInt8(Value: bytes, Endian: Endian = "little") -> int:
150
+ """Unpack an unsigned 8-bit integer from exactly one byte."""
151
+ ...
152
+
153
+ def UnPackUInt16(Value: bytes, Endian: Endian = "little") -> int:
154
+ """Unpack an unsigned 16-bit integer from exactly two bytes."""
155
+ ...
156
+
157
+ def UnPackUInt32(Value: bytes, Endian: Endian = "little") -> int:
158
+ """Unpack an unsigned 32-bit integer from exactly four bytes."""
159
+ ...
160
+
161
+ def UnPackUInt64(Value: bytes, Endian: Endian = "little") -> int:
162
+ """Unpack an unsigned 64-bit integer from exactly eight bytes."""
163
+ ...
164
+
165
+ def UnPackFloat16(Value: bytes, Endian: Endian = "little") -> float:
166
+ """Unpack an IEEE-754 binary16 value from exactly two bytes."""
167
+ ...
168
+
169
+ def UnPackFloat32(Value: bytes, Endian: Endian = "little") -> float:
170
+ """Unpack an IEEE-754 binary32 value from exactly four bytes."""
171
+ ...
172
+
173
+ def UnPackFloat64(Value: bytes, Endian: Endian = "little") -> float:
174
+ """Unpack an IEEE-754 binary64 value from exactly eight bytes."""
175
+ ...
176
+
177
+ def UnPackBool(Value: bytes, Endian: Endian = "little") -> bool:
178
+ """Unpack a Boolean byte; only zero and one are valid."""
179
+ ...
180
+
181
+ def UnPackBools(Value: bytes, Endian: Endian = "little") -> list[bool]:
182
+ """Unpack each input byte into eight Booleans in the selected bit order."""
183
+ ...
184
+
185
+ def UnPackPointer(Value: bytes, Endian: Endian = "little") -> int:
186
+ """Unpack an unsigned 64-bit pointer representation."""
187
+ ...
@@ -0,0 +1,3 @@
1
+ """Binary packing and unpacking."""
2
+
3
+ from BinaryPacking.Packing import *
BinaryPacking/py.typed ADDED
File without changes
BinaryPacking/setup.py ADDED
@@ -0,0 +1,41 @@
1
+ from pathlib import Path
2
+
3
+ from setuptools import Extension, setup
4
+
5
+ here = Path(__file__).parent
6
+
7
+ setup(
8
+ name="BinaryPacking",
9
+ version="1.0.0",
10
+ description="Fast C extension for packing and unpacking numeric values as binary data.",
11
+ long_description=(here / "README.md").read_text(encoding="utf-8"),
12
+ long_description_content_type="text/markdown",
13
+ author="ItsRealAwi",
14
+ license="MIT",
15
+ license_files=["LICENSE"],
16
+ url="https://github.com/ItsRealAwi/BinaryPacking",
17
+ python_requires=">=3.10,<3.17",
18
+ packages=["BinaryPacking"],
19
+ package_dir={"BinaryPacking": "."},
20
+ package_data={"BinaryPacking": ["Packing.pyi", "py.typed"]},
21
+ include_package_data=True,
22
+ ext_modules=[Extension("BinaryPacking.Packing", sources=["Packing.c"])],
23
+ zip_safe=False,
24
+ keywords=["binary", "pack", "unpack", "struct", "serialization"],
25
+ classifiers=[
26
+ "Development Status :: 4 - Beta",
27
+ "Intended Audience :: Developers",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Programming Language :: C",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Programming Language :: Python :: 3.13",
35
+ "Programming Language :: Python :: 3.14",
36
+ "Programming Language :: Python :: 3.15",
37
+ "Programming Language :: Python :: 3.16",
38
+ "Programming Language :: Python :: Implementation :: CPython",
39
+ "Typing :: Typed",
40
+ ],
41
+ )
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: BinaryPacking
3
+ Version: 1.0.0
4
+ Summary: Fast C extension for packing and unpacking numeric values as binary data.
5
+ Home-page: https://github.com/ItsRealAwi/BinaryPacking
6
+ Author: ItsRealAwi
7
+ License: MIT
8
+ Keywords: binary,pack,unpack,struct,serialization
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: C
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
20
+ Classifier: Programming Language :: Python :: 3.16
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10,<3.17
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Dynamic: author
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: keywords
32
+ Dynamic: license
33
+ Dynamic: license-file
34
+ Dynamic: requires-python
35
+ Dynamic: summary
36
+
37
+ # BinaryPacking
38
+
39
+ C extension for packing and unpacking numeric values (ints, floats, bools, pointers) as binary data.
40
+ Supports fixed-width little/big-endian formats and dense variable-length integers.
41
+
42
+ ## Install
43
+
44
+ ```
45
+ pip install BinaryPacking
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ```python
51
+ from BinaryPacking import Packing
52
+
53
+ Packing.PackInt32(258) # b'\x02\x01\x00\x00'
54
+ Packing.UnPackInt32(b"\x02\x01\x00\x00") # 258
55
+ Packing.PackUInt32(0x1234, "big") # b'\x00\x00\x12\x34'
56
+ ```
57
+
58
+ ## Build from source
59
+
60
+ - Windows: `build.bat` (also `build.bat wheel`, `build.bat clean`)
61
+ - Make: `make build`, `make wheel`, `make dist`, `make upload`, `make clean`
62
+
63
+ ## License
64
+
65
+ MIT
@@ -0,0 +1,10 @@
1
+ BinaryPacking/Packing.cp313-win_amd64.pyd,sha256=GCpeY55mSidkxlrguMfTzIgWs4alhzrQG01GWCsE_CQ,39936
2
+ BinaryPacking/Packing.pyi,sha256=CV0UefZ9267P2Aobgb-iJjCF-TI-vCYz6f_PEN6y8jk,6910
3
+ BinaryPacking/__init__.py,sha256=RcvDh9Q_rlkOQA4vARglsx5Qz9CGn84m4XUesK3D0VI,74
4
+ BinaryPacking/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ BinaryPacking/setup.py,sha256=t9GqY2BxCZFxFM5Aa4x7FsqJgDrri3eeppXqsPKP2aw,1602
6
+ binarypacking-1.0.0.dist-info/licenses/LICENSE,sha256=3iXok-LX-sIhyUHh5ksnOzSMHo14vhqin5cg4T6cAHc,1088
7
+ binarypacking-1.0.0.dist-info/METADATA,sha256=hds_pyXkFlb4INK8mWPJji37BqxrU9OqdmVVILPFMXA,1977
8
+ binarypacking-1.0.0.dist-info/WHEEL,sha256=0LUNoHxLvcpw9db_x0XozE5jW73-_GOAO7fDDJ4Xt4Q,101
9
+ binarypacking-1.0.0.dist-info/top_level.txt,sha256=Bc0NroXTIcwaob20BzZwKxSd6ORYsPFmaKbs3VpupAo,14
10
+ binarypacking-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ItsRealAwi
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ BinaryPacking