Skip to main content

Python implementation of a fast, compact binary wire format for modern data transport.

Project description

Twilic (Python)

Python implementation of the Twilic wire format and session-aware encoder/decoder.

This package's default encode / decode API targets Twilic v2.

What this package provides

  • Dynamic encoding/decoding (encode, decode)
  • Schema-aware encoding (encode_with_schema)
  • Batch and micro-batch encoding (encode_batch, SessionEncoder.encode_micro_batch)
  • Stateful features (base snapshots, state patch, template batch, control stream, trained dictionary)

Project layout

twilic-python/
  src/twilic/                     # wire, model, codec, session, protocol, v2
  tests/                          # spec conformance and interop tests
  scripts/                        # Rust interop fixtures and smoke checks
  docs/

Requirements

  • Python 3.12 or later
  • uv for development

Install

pip install twilic

Or with uv:

uv add twilic

Quick start

import twilic

value = twilic.new_map(
    twilic.entry("id", twilic.new_u64(1001)),
    twilic.entry("name", twilic.new_string("alice")),
)

data = twilic.encode(value)
decoded = twilic.decode(data)

print(twilic.equal(decoded, value))

Session encoder example

import twilic

enc = twilic.new_session_encoder(twilic.default_session_options())

value = twilic.new_map(
    twilic.entry("id", twilic.new_u64(1)),
    twilic.entry("role", twilic.new_string("admin")),
)

enc.encode(value)

Development

Run checks locally:

uv sync
uv run ruff format --check .
uv run ruff check .
uv run pytest

Rust client interop smoke check (Python server -> Rust client):

bash scripts/check-rust-client-interop.sh

Python client interop smoke check (Rust server -> Python client):

bash scripts/check-python-client-interop.sh

Run both directions:

bash scripts/check-interop.sh

Note: interop scripts expect ../twilic-rust to exist as a sibling directory.

Markdown formatting

Documentation is formatted and linted with Prettier and markdownlint (see docs/CONTRIBUTING.md).

CI and release (GitHub Actions)

  • CI workflow: .github/workflows/ci.yml
  • Interop workflow: .github/workflows/interop.yml
  • Release workflow: .github/workflows/publish-pypi.yml (tag v* must match pyproject.toml version)

Spec parity

This package mirrors the Twilic wire format spec at twilic/twilic and stays in lockstep with the Rust, Go, and Zig reference implementations.

See docs/SPEC-TEST-TRACEABILITY.md for the spec-section to test mapping.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twilic-3.0.0.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twilic-3.0.0-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file twilic-3.0.0.tar.gz.

File metadata

  • Download URL: twilic-3.0.0.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for twilic-3.0.0.tar.gz
Algorithm Hash digest
SHA256 6dac625277da85d752d377f26cac51ad3c52b540a2c3ae69200869955490e064
MD5 fac200e69607c02decc117f03f28120b
BLAKE2b-256 7c984f2378ca6cc432afa3abf385a2f2de8eac36b75167b08cfa7b650afaa70e

See more details on using hashes here.

Provenance

The following attestation bundles were made for twilic-3.0.0.tar.gz:

Publisher: publish-pypi.yml on twilic/twilic-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file twilic-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: twilic-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for twilic-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 834e300da1ba5496a40776479b19fb756f0154c37bd303f09fdb3bc99e0b19cd
MD5 9360779a4379682b0611a804f9fbae41
BLAKE2b-256 2ca078ffad7ae14cf3e5f7cee2e4d79e1ed9b7bf52caaef12f690bddf29c685c

See more details on using hashes here.

Provenance

The following attestation bundles were made for twilic-3.0.0-py3-none-any.whl:

Publisher: publish-pypi.yml on twilic/twilic-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page