tsrkit-types 0.1.9__tar.gz → 0.2.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.
Files changed (56) hide show
  1. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/MANIFEST.in +3 -1
  2. tsrkit_types-0.2.0/PKG-INFO +154 -0
  3. tsrkit_types-0.2.0/README.md +112 -0
  4. tsrkit_types-0.2.0/benchmark.md +53 -0
  5. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/pyproject.toml +10 -1
  6. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/pytest.ini +2 -1
  7. tsrkit_types-0.2.0/setup.py +9 -0
  8. tsrkit_types-0.2.0/tests/test_native_optional.py +43 -0
  9. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/__init__.py +3 -1
  10. tsrkit_types-0.2.0/tsrkit_types/_native.c +3832 -0
  11. tsrkit_types-0.2.0/tsrkit_types/bits.py +27 -0
  12. tsrkit_types-0.2.0/tsrkit_types/bytearray.py +11 -0
  13. tsrkit_types-0.2.0/tsrkit_types/bytes.py +51 -0
  14. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/choice.py +1 -3
  15. tsrkit_types-0.2.0/tsrkit_types/dictionary.py +95 -0
  16. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/enum.py +1 -1
  17. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/integers.py +24 -66
  18. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/sequences.py +70 -13
  19. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/string.py +8 -6
  20. tsrkit_types-0.2.0/tsrkit_types.egg-info/PKG-INFO +154 -0
  21. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types.egg-info/SOURCES.txt +3 -0
  22. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types.egg-info/requires.txt +1 -0
  23. tsrkit_types-0.1.9/PKG-INFO +0 -833
  24. tsrkit_types-0.1.9/README.md +0 -792
  25. tsrkit_types-0.1.9/setup.py +0 -7
  26. tsrkit_types-0.1.9/tsrkit_types/bits.py +0 -134
  27. tsrkit_types-0.1.9/tsrkit_types/bytearray.py +0 -39
  28. tsrkit_types-0.1.9/tsrkit_types/bytes.py +0 -87
  29. tsrkit_types-0.1.9/tsrkit_types/dictionary.py +0 -146
  30. tsrkit_types-0.1.9/tsrkit_types.egg-info/PKG-INFO +0 -833
  31. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/CHANGELOG.md +0 -0
  32. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/CONTRIBUTING.md +0 -0
  33. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/LICENSE +0 -0
  34. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/setup.cfg +0 -0
  35. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_bits.py +0 -0
  36. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_bytearray.py +0 -0
  37. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_bytes.py +0 -0
  38. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_choices.py +0 -0
  39. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_containers.py +0 -0
  40. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_enums.py +0 -0
  41. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_int.py +0 -0
  42. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_integers.py +0 -0
  43. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_network.py +0 -0
  44. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_seq.py +0 -0
  45. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_strings.py +0 -0
  46. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_struct.py +0 -0
  47. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/test_structs.py +0 -0
  48. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tests/type_hints/test_struct_serde.py +0 -0
  49. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/bool.py +0 -0
  50. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/bytes_common.py +0 -0
  51. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/itf/codable.py +0 -0
  52. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/null.py +0 -0
  53. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/option.py +0 -0
  54. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types/struct.py +0 -0
  55. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types.egg-info/dependency_links.txt +0 -0
  56. {tsrkit_types-0.1.9 → tsrkit_types-0.2.0}/tsrkit_types.egg-info/top_level.txt +0 -0
@@ -2,11 +2,13 @@ include README.md
2
2
  include LICENSE
3
3
  include CHANGELOG.md
4
4
  include CONTRIBUTING.md
5
+ include benchmark.md
5
6
  include pytest.ini
6
7
  include pyproject.toml
7
8
  include setup.py
8
9
 
9
10
  recursive-include tsrkit_types *.py
11
+ recursive-include tsrkit_types *.c
10
12
  recursive-include tests *.py
11
13
 
12
14
  exclude .gitignore
@@ -16,4 +18,4 @@ exclude .pytest_cache/*
16
18
  exclude __pycache__/*
17
19
  exclude *.pyc
18
20
  exclude .coverage
19
- exclude htmlcov/*
21
+ exclude htmlcov/*
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: tsrkit-types
3
+ Version: 0.2.0
4
+ Summary: Performant Python Typings library for type-safe binary serialization, JSON encoding, and data validation with zero dependencies
5
+ Author-email: chainscore-labs <hello@chainscore.finance>, prasad-kumkar <prasad@chainscore.finance>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/chainscore/tsrkit-types
8
+ Project-URL: Repository, https://github.com/chainscore/tsrkit-types
9
+ Project-URL: Issues, https://github.com/chainscore/tsrkit-types/issues
10
+ Project-URL: Documentation, https://github.com/chainscore/tsrkit-types#readme
11
+ Project-URL: Changelog, https://github.com/chainscore/tsrkit-types/blob/main/CHANGELOG.md
12
+ Keywords: serialization,binary,encoding,types,codable,json,validation,data-types,type-safety,zero-copy,protocol,struct,networking,performance,bytes,integers,strings
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Classifier: Topic :: System :: Networking
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Database
26
+ Classifier: Topic :: Utilities
27
+ Classifier: Topic :: System :: Archiving
28
+ Classifier: Topic :: Communications
29
+ Classifier: Typing :: Typed
30
+ Requires-Python: <3.13,>=3.11
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
36
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
37
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
38
+ Requires-Dist: pytest-timeout>=2.1.0; extra == "dev"
39
+ Requires-Dist: pytest-xdist>=3.0.0; extra == "dev"
40
+ Requires-Dist: ruff>=0.6.0; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # TSRKit Types
44
+
45
+ [![PyPI](https://img.shields.io/pypi/v/tsrkit-types.svg)](https://pypi.org/project/tsrkit-types/)
46
+ [![Python](https://img.shields.io/pypi/pyversions/tsrkit-types.svg)](https://pypi.org/project/tsrkit-types/)
47
+ [![CI](https://github.com/Chainscore/tsrkit-types/actions/workflows/ci.yml/badge.svg)](https://github.com/Chainscore/tsrkit-types/actions/workflows/ci.yml)
48
+ [![Release](https://github.com/Chainscore/tsrkit-types/actions/workflows/release.yml/badge.svg)](https://github.com/Chainscore/tsrkit-types/actions/workflows/release.yml)
49
+ [![License](https://img.shields.io/github/license/Chainscore/tsrkit-types.svg)](https://github.com/Chainscore/tsrkit-types/blob/main/LICENSE)
50
+
51
+ A high‑performance, strongly‑typed Python serialization library with built‑in JSON support. TSRKit Types provides a concise type system for integers, bytes, strings, bits, sequences, dictionaries, enums, and structs with deterministic, validated encoding.
52
+
53
+ ## Highlights
54
+
55
+ - Native C extension for performance‑critical encode/decode paths
56
+ - Deterministic binary encoding and JSON serialization
57
+ - Strong runtime validation with type‑safe containers
58
+ - Clean, small API designed for application‑level data modeling
59
+
60
+ ## Installation
61
+
62
+ ### Wheels (recommended)
63
+
64
+ ```bash
65
+ pip install tsrkit-types
66
+ ```
67
+
68
+ ### Build from source
69
+
70
+ ```bash
71
+ pip install .
72
+ ```
73
+
74
+ The native extension is required. Wheels are provided for macOS and Linux.
75
+
76
+ ## Quickstart
77
+
78
+ ```python
79
+ from tsrkit_types import Uint, U16, String, Bytes, Bits, TypedVector, Dictionary, structure
80
+
81
+ # Integers
82
+ value = Uint(1000)
83
+ encoded = value.encode()
84
+ decoded = Uint.decode(encoded)
85
+
86
+ # Fixed-width integer
87
+ port = U16(8080)
88
+
89
+ # Strings and bytes
90
+ name = String("alice")
91
+ blob = Bytes(b"payload")
92
+
93
+ # Bits
94
+ flags = Bits([True, False, True, True])
95
+
96
+ # Typed container
97
+ VecU16 = TypedVector[U16]
98
+ ports = VecU16([U16(80), U16(443)])
99
+
100
+ # Dictionary with typed keys/values
101
+ Config = Dictionary[String, U16]
102
+ config = Config({String("port"): U16(8080)})
103
+
104
+ # Structs
105
+ @structure
106
+ class Person:
107
+ name: String
108
+ age: U16
109
+
110
+ p = Person(name=String("bob"), age=U16(42))
111
+
112
+ # Binary + JSON
113
+ binary = p.encode()
114
+ json_data = p.to_json()
115
+ ```
116
+
117
+ ## Type Overview
118
+
119
+ - **Integers**: `Uint`, `U8`, `U16`, `U32`, `U64`
120
+ - **Strings**: `String`
121
+ - **Bytes**: `Bytes`, `Bytes16`, `Bytes32`, `Bytes64`, `Bytes128`, `Bytes256`, `Bytes512`, `Bytes1024`, `ByteArray`
122
+ - **Bits**: `Bits`
123
+ - **Sequences**: `Seq`, `Vector`, `Array`, `TypedVector`, `TypedArray`, `BoundedVector`, `TypedBoundedVector`
124
+ - **Dictionary**: `Dictionary`
125
+ - **Enums**: `Enum`
126
+ - **Structs**: `structure`
127
+ - **Choice/Option**: `Choice`, `Option`
128
+
129
+ ## Encoding Notes
130
+
131
+ - Fixed‑width integers are little‑endian.
132
+ - Variable‑length integers use a compact prefix encoding optimized for smaller values.
133
+ - Dictionaries encode in sorted key order for determinism.
134
+
135
+ ## Benchmarks
136
+
137
+ See `benchmark.md` for current results and Python/stdlib baselines. Raw benchmark outputs are written to:
138
+
139
+ - `benchmarks/out/bench_results.json`
140
+ - `benchmarks/out/bench_profiles.json`
141
+
142
+ ## Development
143
+
144
+ ### Tests
145
+
146
+ ```bash
147
+ uv run pytest
148
+ ```
149
+
150
+ ### Linting
151
+
152
+ ```bash
153
+ uv run ruff check .
154
+ ```
@@ -0,0 +1,112 @@
1
+ # TSRKit Types
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/tsrkit-types.svg)](https://pypi.org/project/tsrkit-types/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/tsrkit-types.svg)](https://pypi.org/project/tsrkit-types/)
5
+ [![CI](https://github.com/Chainscore/tsrkit-types/actions/workflows/ci.yml/badge.svg)](https://github.com/Chainscore/tsrkit-types/actions/workflows/ci.yml)
6
+ [![Release](https://github.com/Chainscore/tsrkit-types/actions/workflows/release.yml/badge.svg)](https://github.com/Chainscore/tsrkit-types/actions/workflows/release.yml)
7
+ [![License](https://img.shields.io/github/license/Chainscore/tsrkit-types.svg)](https://github.com/Chainscore/tsrkit-types/blob/main/LICENSE)
8
+
9
+ A high‑performance, strongly‑typed Python serialization library with built‑in JSON support. TSRKit Types provides a concise type system for integers, bytes, strings, bits, sequences, dictionaries, enums, and structs with deterministic, validated encoding.
10
+
11
+ ## Highlights
12
+
13
+ - Native C extension for performance‑critical encode/decode paths
14
+ - Deterministic binary encoding and JSON serialization
15
+ - Strong runtime validation with type‑safe containers
16
+ - Clean, small API designed for application‑level data modeling
17
+
18
+ ## Installation
19
+
20
+ ### Wheels (recommended)
21
+
22
+ ```bash
23
+ pip install tsrkit-types
24
+ ```
25
+
26
+ ### Build from source
27
+
28
+ ```bash
29
+ pip install .
30
+ ```
31
+
32
+ The native extension is required. Wheels are provided for macOS and Linux.
33
+
34
+ ## Quickstart
35
+
36
+ ```python
37
+ from tsrkit_types import Uint, U16, String, Bytes, Bits, TypedVector, Dictionary, structure
38
+
39
+ # Integers
40
+ value = Uint(1000)
41
+ encoded = value.encode()
42
+ decoded = Uint.decode(encoded)
43
+
44
+ # Fixed-width integer
45
+ port = U16(8080)
46
+
47
+ # Strings and bytes
48
+ name = String("alice")
49
+ blob = Bytes(b"payload")
50
+
51
+ # Bits
52
+ flags = Bits([True, False, True, True])
53
+
54
+ # Typed container
55
+ VecU16 = TypedVector[U16]
56
+ ports = VecU16([U16(80), U16(443)])
57
+
58
+ # Dictionary with typed keys/values
59
+ Config = Dictionary[String, U16]
60
+ config = Config({String("port"): U16(8080)})
61
+
62
+ # Structs
63
+ @structure
64
+ class Person:
65
+ name: String
66
+ age: U16
67
+
68
+ p = Person(name=String("bob"), age=U16(42))
69
+
70
+ # Binary + JSON
71
+ binary = p.encode()
72
+ json_data = p.to_json()
73
+ ```
74
+
75
+ ## Type Overview
76
+
77
+ - **Integers**: `Uint`, `U8`, `U16`, `U32`, `U64`
78
+ - **Strings**: `String`
79
+ - **Bytes**: `Bytes`, `Bytes16`, `Bytes32`, `Bytes64`, `Bytes128`, `Bytes256`, `Bytes512`, `Bytes1024`, `ByteArray`
80
+ - **Bits**: `Bits`
81
+ - **Sequences**: `Seq`, `Vector`, `Array`, `TypedVector`, `TypedArray`, `BoundedVector`, `TypedBoundedVector`
82
+ - **Dictionary**: `Dictionary`
83
+ - **Enums**: `Enum`
84
+ - **Structs**: `structure`
85
+ - **Choice/Option**: `Choice`, `Option`
86
+
87
+ ## Encoding Notes
88
+
89
+ - Fixed‑width integers are little‑endian.
90
+ - Variable‑length integers use a compact prefix encoding optimized for smaller values.
91
+ - Dictionaries encode in sorted key order for determinism.
92
+
93
+ ## Benchmarks
94
+
95
+ See `benchmark.md` for current results and Python/stdlib baselines. Raw benchmark outputs are written to:
96
+
97
+ - `benchmarks/out/bench_results.json`
98
+ - `benchmarks/out/bench_profiles.json`
99
+
100
+ ## Development
101
+
102
+ ### Tests
103
+
104
+ ```bash
105
+ uv run pytest
106
+ ```
107
+
108
+ ### Linting
109
+
110
+ ```bash
111
+ uv run ruff check .
112
+ ```
@@ -0,0 +1,53 @@
1
+ # Benchmarks
2
+
3
+ This document records the latest benchmark run and the Python/stdlib baselines used for comparison.
4
+ All timings are **seconds for 20,000 runs** on the local machine; results are not directly comparable across hardware or Python versions.
5
+
6
+ ## How To Run
7
+
8
+ ```bash
9
+ PYTHONPATH=. python3.12 benchmarks/bench_types.py
10
+ ```
11
+
12
+ Raw data is written to:
13
+ - `benchmarks/out/bench_results.json`
14
+ - `benchmarks/out/bench_profiles.json`
15
+
16
+ ## Latest Results (Local)
17
+
18
+ **Run date:** 2026-02-04
19
+ **Python:** 3.12.11
20
+ **Runs:** 20,000
21
+
22
+ ### TSRKit Types (selected)
23
+
24
+ | Case | init_s | encode_s | decode_s | json_encode_s | json_decode_s |
25
+ | --- | --- | --- | --- | --- | --- |
26
+ | Uint | 0.008567 | 0.004479 | 0.014276 | 0.002534 | 0.008913 |
27
+ | U16 | 0.008530 | 0.004632 | 0.014242 | 0.002791 | 0.009892 |
28
+ | Bytes(var,64B) | 0.004458 | 0.010630 | 0.008252 | 0.003609 | 0.010214 |
29
+ | ByteArray | 0.003199 | 0.006915 | 0.006440 | 0.003522 | 0.009588 |
30
+ | Bits(var,64b) | 0.011615 | 0.011080 | 0.016224 | 0.007608 | 0.024439 |
31
+ | TypedArray[U16,10] | 0.014253 | 0.006967 | 0.017195 | 0.003189 | 0.152636 |
32
+ | Dictionary[String,U16] | 0.023382 | 0.061991 | 0.149705 | 0.068052 | 0.179980 |
33
+
34
+ ### Python/Stdlib Baselines (selected)
35
+
36
+ | Case | init_s | encode_s | decode_s |
37
+ | --- | --- | --- | --- |
38
+ | PyInt(varint) | 0.002778 | 0.006405 | 0.007207 |
39
+ | PyU16(to_bytes) | 0.004112 | 0.003861 | 0.006797 |
40
+ | PyBytes(var,64B) | 0.003516 | 0.005396 | 0.005538 |
41
+ | PyByteArray(var,64B) | 0.003091 | 0.006694 | 0.006594 |
42
+ | PyBits(var,64b) | 0.006438 | 0.088161 | 0.150918 |
43
+ | PyArray('H',10) | 0.006611 | 0.008616 | 0.006599 |
44
+ | PyDict[str,U16] | 0.003587 | 0.095823 | 0.077303 |
45
+
46
+ ## Notes On Baselines
47
+
48
+ - `PyInt(varint)`: pure-Python varint encoder/decoder (same scheme as `Uint`).
49
+ - `PyU16(to_bytes)`: `int.to_bytes` / `int.from_bytes` for fixed-width integers.
50
+ - `PyBytes(var,64B)` / `PyByteArray(var,64B)`: length-prefixed bytes (varint length).
51
+ - `PyBits(var,64b)`: list[bool] packed/unpacked to bytes in Python.
52
+ - `PyArray('H',10)`: stdlib `array('H')` with `.tobytes()` / `.frombytes()`.
53
+ - `PyDict[str,U16]`: sorted key encode; keys length-prefixed; values fixed 2-byte little-endian.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tsrkit-types"
3
- version = "0.1.9"
3
+ version = "0.2.0"
4
4
  description = "Performant Python Typings library for type-safe binary serialization, JSON encoding, and data validation with zero dependencies"
5
5
  authors = [
6
6
  {name = "chainscore-labs", email = "hello@chainscore.finance"},
@@ -43,6 +43,7 @@ dev = [
43
43
  "pytest-asyncio>=0.21.0",
44
44
  "pytest-timeout>=2.1.0",
45
45
  "pytest-xdist>=3.0.0",
46
+ "ruff>=0.6.0",
46
47
  ]
47
48
 
48
49
  [project.urls]
@@ -55,3 +56,11 @@ Changelog = "https://github.com/chainscore/tsrkit-types/blob/main/CHANGELOG.md"
55
56
  [build-system]
56
57
  requires = ["setuptools>=65.0.0", "wheel"]
57
58
  build-backend = "setuptools.build_meta"
59
+
60
+ [tool.setuptools]
61
+ packages = { find = { include = ["tsrkit_types*"], exclude = ["wheelhouse*"] } }
62
+
63
+ [tool.ruff]
64
+ line-length = 100
65
+ target-version = "py311"
66
+ select = ["E9", "F63", "F7", "F82"]
@@ -12,4 +12,5 @@ addopts =
12
12
  markers =
13
13
  slow: marks tests as slow (deselect with '-m "not slow"')
14
14
  integration: marks tests as integration tests
15
- unit: marks tests as unit tests
15
+ unit: marks tests as unit tests
16
+ perf: marks performance benchmarks
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python3
2
+ """Setup script for tsrkit-types package."""
3
+
4
+ from setuptools import Extension, setup
5
+
6
+ extensions = [Extension("tsrkit_types._native", sources=["tsrkit_types/_native.c"])]
7
+
8
+ # Use pyproject.toml for configuration
9
+ setup(ext_modules=extensions)
@@ -0,0 +1,43 @@
1
+ import pytest
2
+
3
+ _native = pytest.importorskip("tsrkit_types._native")
4
+
5
+ from tsrkit_types import Uint, U16, TypedArray
6
+
7
+
8
+ def test_native_uint_roundtrip():
9
+ values = [0, 1, 127, 128, 255, 1000, 2**32]
10
+ for value in values:
11
+ encoded = _native.uint_encode(value, 0, False)
12
+ assert encoded == Uint(value).encode()
13
+ decoded, size = _native.uint_decode(encoded, 0, 0, False)
14
+ assert decoded == value
15
+ assert size == len(encoded)
16
+
17
+
18
+ def test_native_uint_fixed_roundtrip():
19
+ value = 500
20
+ encoded = _native.uint_encode(value, 2, False)
21
+ assert encoded == U16(value).encode()
22
+ decoded, size = _native.uint_decode(encoded, 0, 2, False)
23
+ assert decoded == value
24
+ assert size == 2
25
+
26
+
27
+ def test_native_bits_pack_unpack():
28
+ bits = [True, False, True, False, True, False, True, False, True]
29
+ packed = _native.pack_bits(bits, len(bits), "msb")
30
+ unpacked = _native.unpack_bits(packed, len(bits), "msb")
31
+ assert unpacked == bits
32
+
33
+
34
+ def test_native_fixed_array_roundtrip():
35
+ arr_cls = TypedArray[U16, 4]
36
+ values = [U16(1), U16(2), U16(3), U16(4)]
37
+ encoded = _native.encode_fixed_array(values, U16.byte_size)
38
+ assert encoded == arr_cls(values).encode()
39
+
40
+ items, size = _native.decode_fixed_array(encoded, 0, 4, U16.byte_size, U16)
41
+ assert size == 4 * U16.byte_size
42
+ assert [int(x) for x in items] == [1, 2, 3, 4]
43
+ assert all(isinstance(x, U16) for x in items)
@@ -8,6 +8,7 @@ serialization capabilities, including integers, strings, containers, and more.
8
8
  # Core interfaces
9
9
  from .itf.codable import Codable
10
10
 
11
+
11
12
  # Integer types
12
13
  from .integers import Uint, U8, U16, U32, U64
13
14
 
@@ -87,9 +88,10 @@ __all__ = [
87
88
 
88
89
  # Structure decorator
89
90
  "structure", "struct",
91
+
90
92
  ]
91
93
 
92
94
  # Version information
93
- __version__ = "0.1.9"
95
+ __version__ = "0.2.0"
94
96
  __author__ = "TSRKit Team"
95
97
  __license__ = "MIT"