Skip to main content

A high-performance TOON (Token Oriented Object Notation) parser and serializer for Python, implemented in Rust.

Project description

TOONS - Token Oriented Object Notation Serializer

PyPI version Python Documentation Status CI License

A high-performance TOON (Token Oriented Object Notation) parser and serializer for Python.

TOONS - Token Oriented Object Notation Serializer - is a fast Rust-based library that provides a Python interface mirroring the json module API, making it easy to work with the TOON format—a token-efficient data serialization format designed specifically for Large Language Models.

Why TOON?

The TOON format achieves 30-60% fewer tokens than equivalent JSON, making it ideal for LLM contexts where token count impacts costs and context capacity.

In this simple example we can achive -40% with respect to JSON:

JSON (26 tokens):

{"users": [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]}

TOON (16 tokens):

users[2]{name,age}:
  Alice,25
  Bob,30

Note: Calculations were done using Anthropic Claude tokenizer, you can experiment with different tokenizer here

Features

  • 🚀 Fast: Rust implementation with PyO3 bindings
  • 📊 Token-Efficient: 30-60% fewer tokens than JSON
  • 🔄 Familiar API: Drop-in replacement for json module
  • Spec Compliant: Full TOON Specification v2.0 support
  • 🐍 Python Native: Works with standard Python types

Quick Start

Installation

pip install toons

Basic Usage

import toons

# Parse TOON string
data = toons.loads("""
name: Alice
age: 30
tags[3]: python,rust,toon
""")
print(data)
# {'name': 'Alice', 'age': 30, 'tags': ['python', 'rust', 'toon']}

# Serialize to TOON
user = {"name": "Bob", "age": 25, "active": True}
print(toons.dumps(user))
# name: Bob
# age: 25
# active: true

File Operations

import toons

# Write to file
with open("data.toon", "w") as f:
    toons.dump({"message": "Hello, TOON!"}, f)

# Read from file
with open("data.toon", "r") as f:
    data = toons.load(f)

Documentation

📖 Read the full documentation at toons.readthedocs.io

Development

# Clone repository
git clone https://github.com/alesanfra/toons.git
cd toons

# Install dependencies
pip install -r requirements-dev.txt

# Build extension
maturin develop

# Run tests
pytest

See the Development Guide for more details.

Contributing

Contributions are welcome! Please follow Conventional Commits and run tests before submitting.

See Contributing Guide for details.

License

This project is licensed under the Apache License 2.0. See 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

toons-0.3.0.tar.gz (76.9 kB view details)

Uploaded Source

Built Distributions

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

toons-0.3.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (315.1 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

toons-0.3.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (332.0 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

toons-0.3.0-cp37-abi3-win_amd64.whl (171.6 kB view details)

Uploaded CPython 3.7+Windows x86-64

toons-0.3.0-cp37-abi3-win32.whl (165.5 kB view details)

Uploaded CPython 3.7+Windows x86

toons-0.3.0-cp37-abi3-musllinux_1_2_x86_64.whl (485.4 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ x86-64

toons-0.3.0-cp37-abi3-musllinux_1_2_i686.whl (518.9 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ i686

toons-0.3.0-cp37-abi3-musllinux_1_2_armv7l.whl (588.0 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARMv7l

toons-0.3.0-cp37-abi3-musllinux_1_2_aarch64.whl (492.1 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

toons-0.3.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (319.3 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

toons-0.3.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (346.9 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

toons-0.3.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (438.5 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

toons-0.3.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (320.4 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

toons-0.3.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (309.9 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

toons-0.3.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (336.5 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.5+ i686

toons-0.3.0-cp37-abi3-macosx_11_0_arm64.whl (283.7 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

toons-0.3.0-cp37-abi3-macosx_10_12_x86_64.whl (290.3 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file toons-0.3.0.tar.gz.

File metadata

  • Download URL: toons-0.3.0.tar.gz
  • Upload date:
  • Size: 76.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for toons-0.3.0.tar.gz
Algorithm Hash digest
SHA256 56bf7ea539546ff8f1a75959485e49b59504970fc4530450cba51491f0d22052
MD5 c211e53d05e9a10c0592eca8a90051bf
BLAKE2b-256 b366b587b0e47f61fd1311f148c8c9b5b67360eb49d8e7cd40cd167ad6e1cce6

See more details on using hashes here.

File details

Details for the file toons-0.3.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.3.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9cd21d034f9d4d88fbd4f6553387681ffec059534dc9d217bd863fd06ee5ecab
MD5 83d9fd54a5cef8b218aded06be68fee9
BLAKE2b-256 ce679ad679cc65086cc6b908ea85e4c676393d26d704fbc5698110ce408d9d43

See more details on using hashes here.

File details

Details for the file toons-0.3.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for toons-0.3.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 895b1ba1988860d51d0ac307b1d310af5f3cca635716d11cccfda5989023e2f1
MD5 c9e4bb36f67c314d784e6349c271cffc
BLAKE2b-256 00bfd36d7dcbfbe6e600580d7abddacc7e9d41b2a0dbab78fdebd262b169ab73

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: toons-0.3.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 171.6 kB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for toons-0.3.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dc7b8ea965e3e89c61c1cdc7458eb47d603ecbeec71f291c7a8097bc7f5d9846
MD5 27aa48b01b37fb655bd0a4c3bfdf476e
BLAKE2b-256 a0a827922bb35a5c7073b7d04663d0835d56ec0f78ecd5e96c309068b1158e29

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-win32.whl.

File metadata

  • Download URL: toons-0.3.0-cp37-abi3-win32.whl
  • Upload date:
  • Size: 165.5 kB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for toons-0.3.0-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 4ccef7991ad7b95dfc7926ae55cbe556d6add15e9f0f126bd91e8a611d6674ab
MD5 e544f2adfc22379648c412718cc5b0aa
BLAKE2b-256 a953b45cb8abb230f81356fd2c66140a6b6547f0a2afbf3a1d53e8dd4d04fc59

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cd49ecbee3fbb9c8600b39e615f254dacbfc3de2ba26f37e2995b4483558c956
MD5 95419acc71c91f29721e3831824f91af
BLAKE2b-256 8dfe051fb7d2629e20b5de7f344153ff2eeaf2f10146bde51d65647c536ed6f0

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 afe64c848295393153613a71573e75c796ed4e1e1e5315a81a32906ad4024c11
MD5 1c8e2b6006f7a33e2d55d572cace2dab
BLAKE2b-256 2b3532853015abf32a0ff7918d0bfb3dd298bb7e2b57bdec221194d7f0d5289f

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 17546d0a9ed7018785885d16fe22ccc281746ee284918be362f8b8220e414da3
MD5 7d4c7322f4e44d2cadf4195e03e33ebf
BLAKE2b-256 54292aeae856a05832be1c32e726eca24c79db5aed727faff7c8946f51c754e0

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1a55c5a7f4b0867ddbd30a8179b8ac3c698c83719b31022e89ba1729d87fbb20
MD5 317d9edd4685418c1710e717cea44c79
BLAKE2b-256 06b9f53ff7063310718be84aa33964a2cebcafb7f7890943c4339e7b8b2cdec9

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0bc9028af5de678ac5205a7b67a81eeafc8655a833c6b38318f19998a31ba4d1
MD5 d39d5b77890eed069adeb318665a5165
BLAKE2b-256 eba39f97f4355b18334526a1f221feab1f8e6895504fa68dd593183e5eca0031

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 297b494aabb04c5adaadf7055dabcd3845ec332d4ca661d0485ad9e0427257fe
MD5 0fa51cbeed5ae442112a9856d2fd93e5
BLAKE2b-256 a95f3b191a80a9cdf63fa2801337b316b0582b4c59641103aa4d39d8c855fe1b

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 dd2aa6b6db0ffd19fad89f6396a1f9b74aca19ee9392f92a1aa1ae54e70d086a
MD5 c31adc332e717aa0833bd399d22f1080
BLAKE2b-256 ce766116ff146d45d45f2e723fdf1555b74757e5cd7fb3013931f087962b259e

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 c83c0ae471ee7bb15765ed5491da4e51842f05f8315eaa8e57b102981bb7bc51
MD5 35fff09a3268fcd36a5e648ba470d787
BLAKE2b-256 fa1d27d176f25f1383d9d59f6b9bd494c6dd12d7fb66f8c0157c73680553090b

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6c5d5f01f0caa0d210b543405cfb7c20bdc3987a6da5f29b163caf1d1728b96f
MD5 5878e2262c9d58b10a7702dda6017996
BLAKE2b-256 4389eaaed8862b3dff6736bd32f00a6ce24d7690194bb14e220dc1934ade01fa

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 861229b6aa4a97bd5bc2bb2c681b66ef121ff89a103edd386b833d54572acc36
MD5 b61a1b9ae635c7469a16f172a121bb9b
BLAKE2b-256 fcb725cf805b6d35c55649298009d6195a02f6c4308fec992d0062ac59e73f76

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4381aaf577feeaf83f7e5f22f18bfa74547c6ed72536c27cf4234d4d68692efd
MD5 8dda5904283e30ccd593680f15ea1870
BLAKE2b-256 50b70e44e680c4a1b8b2a3252a8570c6e767b5535700f31e15ebb3b28a4fa887

See more details on using hashes here.

File details

Details for the file toons-0.3.0-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.3.0-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 29278ffa80cd6ef91e0333530e7e05f96d271fd487b85ca8ad38d2e307d64847
MD5 d3f3897a25a81756972ba43031a7ad26
BLAKE2b-256 87495d3ac47e4cdd8cbd08b7e10413b059aee7957c245104234975d581afe912

See more details on using hashes here.

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