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.1.tar.gz (78.4 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.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (316.8 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

toons-0.3.1-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (334.6 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

toons-0.3.1-cp37-abi3-win_amd64.whl (173.6 kB view details)

Uploaded CPython 3.7+Windows x86-64

toons-0.3.1-cp37-abi3-win32.whl (167.7 kB view details)

Uploaded CPython 3.7+Windows x86

toons-0.3.1-cp37-abi3-musllinux_1_2_x86_64.whl (487.7 kB view details)

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

toons-0.3.1-cp37-abi3-musllinux_1_2_i686.whl (520.9 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ i686

toons-0.3.1-cp37-abi3-musllinux_1_2_armv7l.whl (590.1 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARMv7l

toons-0.3.1-cp37-abi3-musllinux_1_2_aarch64.whl (493.7 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

toons-0.3.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (321.2 kB view details)

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

toons-0.3.1-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (349.7 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

toons-0.3.1-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (441.1 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

toons-0.3.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (322.3 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

toons-0.3.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (311.6 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

toons-0.3.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (339.1 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.5+ i686

toons-0.3.1-cp37-abi3-macosx_11_0_arm64.whl (285.9 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

toons-0.3.1-cp37-abi3-macosx_10_12_x86_64.whl (292.7 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for toons-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7de279f42d318119af539ba36b64751caf0e90215434fd39ebef7f8109844955
MD5 7a61a138a045ba1cd0830f95540b4ff4
BLAKE2b-256 76722bf2e84dec7af9076add1d0a260a6137a468dff76451ce6709727424bd2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76c6bf1648812ff3416069ea56ef7b8142f07bf8e3ce59fb06fa50139edeaee8
MD5 79787f8189687fd9d7acf07d4f434794
BLAKE2b-256 1be69db8e3b28561c26b0ab14eb6785fdf826b069ae3341bd7a7855bcea93ccd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 0c04201ac3b5210a9dd5a9a19f3a3acf12fa193e70a77f35e2d3b0bc37ef6af0
MD5 cc878b6b053c860e5c9f8e0dcd5231d6
BLAKE2b-256 fc93bcd6af31361ed259364d7806c40383ed503081875e388aafba88db029d26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toons-0.3.1-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 173.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.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a1aa8cde4ec0c1713237b72d5da84dd8f34a30d920f395106c9516cec028a03b
MD5 14699ad4062be25d531838f8a1291c9c
BLAKE2b-256 31e225b25ea866a441146469660159896ffa9ae082ba42a2bce62d6c781828e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toons-0.3.1-cp37-abi3-win32.whl
  • Upload date:
  • Size: 167.7 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.1-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 54b45c5989e75c2ca18803dbffd4f88deb46c870a9a28219d27efb324e9c55dd
MD5 2db27111d8a5a51e639323f9e0f972e7
BLAKE2b-256 cc4c857755141bbb6a7f91246c9b094d92070f84a1822c7f7e61e5b58f2a7049

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3f8511b707b27269c8c01daf98bed914fee9bd4edbfa363230ac9c65f6bf3231
MD5 565bca131590d196cb55588445a45528
BLAKE2b-256 0eaa54da09b9dd911048d99e9f3103775ee396f094e330d20bc7b866b90075c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 232e2f884645d50e073f8142764b43c3c25bfacc88391c95bee3a0d0e91f9ce9
MD5 62bb2129166e5db2b5894ba64938ad97
BLAKE2b-256 a37409b87a9c42a2feaf9504f6a17964444efc663668f9586be7edcad1655564

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 e9466456d34195d902c61ebd511f9b3b8f8a3671f5dc11e6b9624e33f2cde80d
MD5 65511a92c6ca815b8dcb287c0b864e36
BLAKE2b-256 fcc2c5d5f2a6b8150610c6eb23a12e8cc13323b46fbe838f05ab68bcbcc5fcc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 48fba084e84e8c5e7db67c89fcb85d5710d75b950cc0c875b3f08e247b5521d8
MD5 aa81285ff5da9a393dd3d56bcdc8a3b5
BLAKE2b-256 6305150c971232dddc65ac47cec0b52d8acae96ca5d479686c9c08f5208fc76c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e934c7445a51473d2a2439105b26b8d370ff6f2a74eb7efbcc1c7b1079832300
MD5 bd67509421508687c016039f2ed2022f
BLAKE2b-256 a047d6b2f2fb210ad718f2010dcbee8b1d751974cfe4fb20712f6a3d80f67e2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 f9093d95569322d6d24de4e27fbf423f75d383e91a6100315b9c0e4e3ef5c943
MD5 0f712c3d57111c3548ecd9f665846b4f
BLAKE2b-256 b8701f6bfa52dd2984a3d95406897d248d311f1f07ba17e0730290bdb1555d9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 3420d27c822e6ad10bd10a034ec2fbce62e5059da297844aadcf21f8cad03696
MD5 d82ef8ff4151e100cd0b038bf89eac6b
BLAKE2b-256 36d7f916567a14b342195b043a44aa28aa731abe28e23e245caaa8bfedbf7dd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 a3fea858e5571299507e8239642a3750dad443d80f9866c1c2a6a2ce9cf01d49
MD5 2705ad8a288a9fd189d6da8b5cbb98fd
BLAKE2b-256 7249eb90fd9748ed5192e050a4d45d93c5cd2061cce70558cce70d81c667d85b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c3336fb4c3eacfffcfa2fd9efcee48b77c1e263200094d60d8fd622e41287a20
MD5 3dd7201401c9456721fd5a93fd6d5400
BLAKE2b-256 b699437b429accd5065a9e59426e4f983241a0903585939e20b2aaa7a2c1719e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 2ede420c7f3019eacc339364a9dd4ade8de1b9419117601bd83a301b89457ae8
MD5 68bb1b7401828126c39f29dab5b2be79
BLAKE2b-256 1375238ec5d4d2f469094ec31ad4b5a8b92321080d81e2ddeef7d9a68d8af4dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81dbbf9d64b2e843a8e6bfbd55741be8375890dc3f059da8d2be9950190c6798
MD5 a2ff3b0023113ced825c4a575bb55d86
BLAKE2b-256 8b855c59a9134148c5a7c69e444fa3a219faf998eeb5f83b0919dc88fc506584

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.3.1-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 405d68293ae33ad2197a476b13177944bd2a3b8b3dd4deed3c46ba5fc42f54ba
MD5 deceb4062b06b2764de6359f055830d6
BLAKE2b-256 69c1b41f374e99bcd1981006ab553bf55740352da263f948f398a884032f81f0

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