Skip to content

toon-codec v1.0.1 - PyPI Release

Latest

Choose a tag to compare

@Mathews-Tom Mathews-Tom released this 16 Nov 23:12
· 3 commits to main since this release

Overview

First public release of toon-codec on PyPI - a production-ready Python implementation of Token-Oriented Object Notation (TOON) v1.5+, delivering 30-60% token savings over JSON for
LLM applications.

Installation

pip install toon-codec


# With optional token counting:
pip install toon-codec[tokenizer]

Highlights

Token Efficiency

  • 30-60% reduction in token usage compared to JSON
  • Ideal for LLM API cost optimization
  • Tabular data achieves up to 65% savings

Production Ready

  • Full TOON v1.5+ specification compliance
  • 1887+ tests with 85%+ code coverage
  • Roundtrip fidelity guaranteed: decode(encode(data)) == data
  • Zero external dependencies for core functionality
  • Type-safe with mypy strict mode compliance

Key Features

  • Core API: encode(), decode(), smart_encode()
  • Intelligent Format Selection: Auto-detect optimal serialization format
  • Type System: 12 built-in handlers (UUID, datetime, bytes, Enum, etc.)
  • Reference Tracking: Efficient relational data encoding
  • Graph Support: Handle circular references
  • Sparse Arrays: Optional field markers and polymorphic arrays
  • CLI Interface: Command-line tool for TOON operations

Quick Example

from pytoon import encode, decode

# Tabular data - maximum savings
users = [
    {"id": 1, "name": "Alice", "role": "admin"},
    {"id": 2, "name": "Bob", "role": "user"},
]

toon = encode(users)
# [2]{id,name,role}
# 1,Alice,admin
# 2,Bob,user

assert decode(toon) == users  # Perfect roundtrip

Performance

Data Type Token Savings
Tabular arrays 55-65%
Mixed structures 35-50%
Nested objects 30-40%
Simple key-value 20-30%
  • Time/Space Complexity: O(n)
  • Speed: <100ms for 1-10KB datasets
  • Validation Overhead: <5%

What's Changed in v1.0.1

  • Renamed PyPI package to toon-codec (import remains from pytoon import ...)
  • Comprehensive README with examples, metrics, and roadmap
  • Added CHANGELOG.md with detailed release notes
  • Updated license format for PEP 639 compliance

Links

Full Changelog

See CHANGELOG.md for complete release notes.


Note: Install as pip install toon-codec, import as from pytoon import encode, decode