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 PyPI Downloads 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.

TOONS is officially listed among the community implementations of the TOON format.

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.4.tar.gz (61.0 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.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (342.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

toons-0.5.4-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (360.7 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

toons-0.5.4-cp37-abi3-win_amd64.whl (196.1 kB view details)

Uploaded CPython 3.7+Windows x86-64

toons-0.5.4-cp37-abi3-win32.whl (189.4 kB view details)

Uploaded CPython 3.7+Windows x86

toons-0.5.4-cp37-abi3-musllinux_1_2_x86_64.whl (549.7 kB view details)

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

toons-0.5.4-cp37-abi3-musllinux_1_2_i686.whl (581.2 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ i686

toons-0.5.4-cp37-abi3-musllinux_1_2_armv7l.whl (618.7 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARMv7l

toons-0.5.4-cp37-abi3-musllinux_1_2_aarch64.whl (510.6 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

toons-0.5.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (346.6 kB view details)

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

toons-0.5.4-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (371.9 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

toons-0.5.4-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (451.9 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

toons-0.5.4-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (343.7 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

toons-0.5.4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (335.2 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

toons-0.5.4-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (364.6 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.5+ i686

toons-0.5.4-cp37-abi3-macosx_11_0_arm64.whl (302.0 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

toons-0.5.4-cp37-abi3-macosx_10_12_x86_64.whl (309.1 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.4.tar.gz
Algorithm Hash digest
SHA256 eae5974e9a73104d3ad01473124585f728bcf9200ad343899da7495381e010d8
MD5 35206ccba4d6fd5605cf19d216bd960b
BLAKE2b-256 f24046540b2026506c3bba143f3778123159a828c7a3c4ec0697b740f3fbe539

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 260de1ee7b3224b990ada4fa019213732b5305379e27d80d41c3fd87e05acb08
MD5 d17c70e0aed997e41f0ae482e4d6be9f
BLAKE2b-256 f2ab9d6f107edbc4b06529245398a705f7c1b098395c7191122b0c484e41f168

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 8020aba9159db1723d53679e8ca41e409241686c27150bbc988fc8d6c899a5f3
MD5 d9094b4bec0d5e0ff3e999edfa4d47b5
BLAKE2b-256 ea13703b1c9555ed8d0f22704a910bee1f4eb386681bd701b51412b89a680e4e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.4-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5074c29a6ae1821759cdbbf175c13ce91fbbb476dca70f333cf27cd5f86d570e
MD5 07cf5891290bed9801f25931097697d9
BLAKE2b-256 55a789cb53a6b8586f83bef9588333d78214e7435d589e0d08f0befe033c3c9c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.4-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 7eb2af0d0e47e569fd78b330374867d9627c994690e88f96072e947fffe915dd
MD5 1a328be469a5ac121363dddfbf53c831
BLAKE2b-256 01bcefd4c0d7162cd84b7d2f4c58abe50df63458a06df909b89bf78adc0a3000

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e70c5118971de438c83d366b169dc69162013eaa606666e376d4526bf35b046d
MD5 0f475c0526e2e3cbc1a76ebfacf0127a
BLAKE2b-256 f0bc274be23c14ce69f51703861a2c3733257fa662199906211a04b26ff79c95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 a4a04f42bb8496c29dc5024321663667bddd7787bc80e17fd46dd166127d1c6c
MD5 0f0349112a5bcf866d5ffe0a9a595ec1
BLAKE2b-256 33cd85c0b497ca1c690d23c3ab7b69fc04772e05da36f3f944aa34e35b74f98e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 eafd7c55d18dfc8df000e67ce0b033d2c65928b824de4897aab567f18f9323fc
MD5 66509f96cbb6455987aba7f685668cb7
BLAKE2b-256 80cc0fabcb340af0157ee0f3c4f5c3972f2097fccb5058d4d3fadeb632eee9dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 732b28d04ad937dc4553d72eae5e997193a3533a6115306f20a3a192b38d155f
MD5 e0b1d68f63df2902a1050d7cacd77e22
BLAKE2b-256 ffd9cb9a6325184b3a162e75ab5121c35a7bc80aed930fdbace4214c511b98dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72d83abe984f6c30913d828e3e7d1ca1bd01c17cbaaf15cfefc4cab044467057
MD5 3cfc8c9e6795231bd8b4a7ec76f9a63f
BLAKE2b-256 eda21068e1441f159ffdfbea899ba899701a201b0af305f68402527448d9d975

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 ae6ab9bce7c962f771a0c8c7acade6a05b20335ecbbe16b5af4a89b4ece791a6
MD5 2e9ced5fdd557dbf14ded121fe1da882
BLAKE2b-256 89c1f50cd0444903dae590823098ba8dbf3bb3aae5e4fee9ea9cfee218c195b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 070334a8f6e8feaf7dee1450fcb284d75f2a8248ee089e921f4ee83fb383cef3
MD5 a63aec7c25a47241aa7c4e4bef3decf3
BLAKE2b-256 1cccc7211e7b11f651769806616d8332a812e2d6d78c518c2e2f324aeec22751

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8b0e915fad2e2daac2d97369d67e4d48904d5ea5cd96f6804911868c7c0895ac
MD5 6d70de117509ab7aafce4ac8cec30ac3
BLAKE2b-256 80bc53f6b575f691d91f318bbae69c5d756f94d97a6ea86e7fd6d2f78dbef35b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e6e1cd0d874a31059011742a91805e35d4595d09f6998b5fe7d73cefc49aba8
MD5 f750e50ce16a50859137ade909b3cd5a
BLAKE2b-256 3f454d52ee63c5ef2c5191f45529f0100ddfa0760b997dc90501c2eaa581e47d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 fc0bf02c315c31b9ee2bca00ee1305ba7f429652c901d98c00368e3cbdab7b1a
MD5 e0b428a5fcab4f09ae1bcabdc12d58d2
BLAKE2b-256 75bf373d13f5f829f4e12816a2e04920ac92402954dcae84154fd94c1fded767

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c290a5d741c86097c0877f2dcf1b989550d3719487d738f49c6fd76da065a5b
MD5 3e8a64b81ee823d2b03c38dee3e578a1
BLAKE2b-256 9d205e6c1d362b0a1a91d779996862093e06f874ba26d97c1225db442fbcc56a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.4-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4b18d7dcaab74e7f38ab9d1e927f1d69b0855d9eecc4155c810ebf4fbe312cd3
MD5 cea500e90ec61011c676db1e1faae584
BLAKE2b-256 41385dcea3bf3b83b39d088a8ea41949cc29c0c398d375300fd37fa1530361a2

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