Performant Python Typings library for type-safe binary serialization, JSON encoding, and data validation with zero dependencies
Project description
TSRKit Types
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.
Highlights
- Native C extension for performance‑critical encode/decode paths
- Deterministic binary encoding and JSON serialization
- Strong runtime validation with type‑safe containers
- Clean, small API designed for application‑level data modeling
Installation
Wheels (recommended)
pip install tsrkit-types
Build from source
pip install .
The native extension is required. Wheels are provided for macOS and Linux.
Quickstart
from tsrkit_types import Uint, U16, String, Bytes, Bits, TypedVector, Dictionary, structure
# Integers
value = Uint(1000)
encoded = value.encode()
decoded = Uint.decode(encoded)
# Fixed-width integer
port = U16(8080)
# Strings and bytes
name = String("alice")
blob = Bytes(b"payload")
# Bits
flags = Bits([True, False, True, True])
# Typed container
VecU16 = TypedVector[U16]
ports = VecU16([U16(80), U16(443)])
# Dictionary with typed keys/values
Config = Dictionary[String, U16]
config = Config({String("port"): U16(8080)})
# Structs
@structure
class Person:
name: String
age: U16
p = Person(name=String("bob"), age=U16(42))
# Binary + JSON
binary = p.encode()
json_data = p.to_json()
Type Overview
- Integers:
Uint,U8,U16,U32,U64 - Strings:
String - Bytes:
Bytes,Bytes16,Bytes32,Bytes64,Bytes128,Bytes256,Bytes512,Bytes1024,ByteArray - Bits:
Bits - Sequences:
Seq,Vector,Array,TypedVector,TypedArray,BoundedVector,TypedBoundedVector - Dictionary:
Dictionary - Enums:
Enum - Structs:
structure - Choice/Option:
Choice,Option
Encoding Notes
- Fixed‑width integers are little‑endian.
- Variable‑length integers use a compact prefix encoding optimized for smaller values.
- Dictionaries encode in sorted key order for determinism.
Benchmarks
See benchmark.md for current results and Python/stdlib baselines. Raw benchmark outputs are written to:
benchmarks/out/bench_results.jsonbenchmarks/out/bench_profiles.json
Development
Tests
uv run pytest
Linting
uv run ruff check .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tsrkit_types-0.2.1.tar.gz.
File metadata
- Download URL: tsrkit_types-0.2.1.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99d7392e6336b0a21b2296409c762e44e65d7bc0b79db26cbc7911ecf45f12fa
|
|
| MD5 |
c135a3ae7a075d76f550d4974757ced0
|
|
| BLAKE2b-256 |
8d2ddf22ac405d9d1fd54614ce0aa5a5ed80d49a3975863c72b6dbe90242db1c
|
Provenance
The following attestation bundles were made for tsrkit_types-0.2.1.tar.gz:
Publisher:
release.yml on Chainscore/tsrkit-types
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsrkit_types-0.2.1.tar.gz -
Subject digest:
99d7392e6336b0a21b2296409c762e44e65d7bc0b79db26cbc7911ecf45f12fa - Sigstore transparency entry: 920065738
- Sigstore integration time:
-
Permalink:
Chainscore/tsrkit-types@133d6e573a082926ba0a5bedb01f4fefe6136a70 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Chainscore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@133d6e573a082926ba0a5bedb01f4fefe6136a70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tsrkit_types-0.2.1-py3-none-any.whl.
File metadata
- Download URL: tsrkit_types-0.2.1-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e66234d662a4ed9a92531a3781e112d7a4a39fb2efc2b9e4ed49c887172ee54
|
|
| MD5 |
8d432ede125aa064d172b5c85f98a0e2
|
|
| BLAKE2b-256 |
96262f27577615ad3a82ff4a4cb27b07a54a99049ace88317b3c412b101d3fba
|
Provenance
The following attestation bundles were made for tsrkit_types-0.2.1-py3-none-any.whl:
Publisher:
release.yml on Chainscore/tsrkit-types
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsrkit_types-0.2.1-py3-none-any.whl -
Subject digest:
7e66234d662a4ed9a92531a3781e112d7a4a39fb2efc2b9e4ed49c887172ee54 - Sigstore transparency entry: 920065743
- Sigstore integration time:
-
Permalink:
Chainscore/tsrkit-types@133d6e573a082926ba0a5bedb01f4fefe6136a70 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Chainscore
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@133d6e573a082926ba0a5bedb01f4fefe6136a70 -
Trigger Event:
push
-
Statement type: