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.

Documentation

📖 Read the full documentation at toons.readthedocs.io.

Quick start pages:

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 v3.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)

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.5.0.tar.gz (101.5 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.5.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (337.4 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

toons-0.5.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (356.9 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

toons-0.5.0-cp37-abi3-win_amd64.whl (190.6 kB view details)

Uploaded CPython 3.7+Windows x86-64

toons-0.5.0-cp37-abi3-win32.whl (184.0 kB view details)

Uploaded CPython 3.7+Windows x86

toons-0.5.0-cp37-abi3-musllinux_1_2_x86_64.whl (543.7 kB view details)

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

toons-0.5.0-cp37-abi3-musllinux_1_2_i686.whl (576.4 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ i686

toons-0.5.0-cp37-abi3-musllinux_1_2_armv7l.whl (608.1 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARMv7l

toons-0.5.0-cp37-abi3-musllinux_1_2_aarch64.whl (505.2 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

toons-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (340.6 kB view details)

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

toons-0.5.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (367.0 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

toons-0.5.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (448.2 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

toons-0.5.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (337.7 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

toons-0.5.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (329.0 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

toons-0.5.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (360.0 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.5+ i686

toons-0.5.0-cp37-abi3-macosx_11_0_arm64.whl (296.7 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

toons-0.5.0-cp37-abi3-macosx_10_12_x86_64.whl (302.8 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8480b5fb3a42275a4c683fdd80cab7abfc28844ffabb91931af615acac8b798a
MD5 d2324ea34ee1caf2d6c8c36b9d45d1db
BLAKE2b-256 7238ae88f3490ba6035ba31f4967ff13c514603a071e19724d0e40298421f130

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 185d9a10ff268a096090fed8d19785e8f27c58145724b52a1984be40a0b3c48d
MD5 537ff656811b0820d1d576ea5ce46ece
BLAKE2b-256 9fe9953b4b88a36ea5e1bfbce1c0f9953ea9d151bcfc17d1c10e2d38e0db87aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4f5a54bf08575a7051dd4eff7bd8d2e1b8c0d3d232a1d7344ec50a20acc7a72e
MD5 910fe6c37a1cdd0a3bfb512ee17b475f
BLAKE2b-256 88a6495f2c240616631b87706dad4f0331ccbe23955fec334971d706d9d55c8e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 17744f78fbcd170398856cc54013cf3ecb7178df988340ffe4bb973696e484bc
MD5 1ed9a44f5f7bb6f941a73421bf131a6c
BLAKE2b-256 b1831c5d092acebc21d7169cf23cd58c5da6978a688be5053795c7273a477ae0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.0-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 48221245ec847ace8ea4d176c25c83ba88546e7641a0a815581e7fdc4cbc6e63
MD5 20320b5c1127e95c5de625da5821fb44
BLAKE2b-256 297b8f6343e997cfb4f6036a33e2523425df17281d4c05bf9af1775709e6db8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 69590271b311bd7609021e1e3046f1fc3670a76f6bfb2f25b83a51fc9ae187b5
MD5 365e8c2b7869ee7ec6c33bd016317a7a
BLAKE2b-256 8b4a2aa6dbb16a0bfc857ad760e2bc92cf41214679fddebd5094df917139ad0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 7c30be6085c06b56d526aa18005ea86e2a89d4bbeac036ad68e31283d60da318
MD5 7a3b31881929c9cf8f595db6cb8900d0
BLAKE2b-256 621cc927fd83c4b4322e039b9a936048e1eda3de968908dfdfe0403c23dbf9c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 3f0f5787234e438a59a7bbeea079e1bbda7fef5ab13a076b13c040383836683a
MD5 5118ded7ca06a52711db2405066d9831
BLAKE2b-256 1367f7a42ce439cd6b66c71b899c7e1302d9e65d58491e2c77e1683a8bfaca3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 39825d7b2c0f5cf6cc69a9554481ab6c5ec43123d47030d63d88f137f6ea8a62
MD5 26e2a43d33856ae131739922e8dbd677
BLAKE2b-256 42f279fcabd119a7cca41a5147159b79e17a53ccc4a75dbbb6689c4bf5218281

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c718324ae90e8e843d6c5496c5c908ee8c0e5c1a47dacad34bda0c44179f5c65
MD5 51b5fbb9b2041099097578a8a8ddec10
BLAKE2b-256 622e76c151d87e6b66ae62353cc74ac8c1ebc2a5c0e6c45ccbd05913557560bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 d9a63797118ad8d9b45e494df3b782abc7c4e51de8170f9dd27a6ed3d920b3ca
MD5 e96baefeb4efaf57a7cea33568aeab70
BLAKE2b-256 5a32ef0f1d43b9e29f0b3709422d67e0b56d99e62c38950d0f48b29bdadb8de0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 cd0e52b89b1544e4c8f27bca7b4fb07d1f72987777e47b66a6dee7977b1c30d2
MD5 1f85aee25295720191d1e19f3623efc2
BLAKE2b-256 1570adad4a3bb818c195c7befcddbd1e7b8cf725affa6310771207431aa89c1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 e75bfc08cb3f8d8221b7632eaef066ebd629efd42b5cd01c40ea510487dede5f
MD5 e9b5c4808a41f73b59d8c6eb2926850a
BLAKE2b-256 508b61eaa4df6539766927d1b32f5c77d7205b7d661b1441102be68873dbb11e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bf397d8a63bf18b2198622e40ba1ec8fc37b7317cebf8a8b0c6a1137d97a6a25
MD5 003f97fa1935d829047c326e6e23eb5a
BLAKE2b-256 5ed64fec2de6f2e72b592f4be39a16ea7ec47938d152757a1a3508f5ccc96c62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 cc8367d6a342ad0f1eacf5287c9dbfc81dfc9cc7056cfe84c0ae740f56a71637
MD5 626f297bc9b57f1264af6637f968a46c
BLAKE2b-256 954c010e6307348ba760a7694651903a03f0eb6f710acae8dd4cfc93d963fcdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 98af5078b3dc073388cd1806c4a427a7cffc17feb1fd6b9bf2d63fc2c98b69bd
MD5 6adf43d4cc428f47950041382a8e914e
BLAKE2b-256 909443174ac30e882bd003c334e0830b2b6cff48471b76cc35b37a3a3cc15db8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.0-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 198bd3ecbec055c6f8a31790cb6349705622417b58986b18765d5a9554611b2f
MD5 b512a283b202d3ecb1be1764267dacd4
BLAKE2b-256 0a086f9fa670f4af4a5123e519969ccee16238c70a57e65bace40bd03083d51b

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