Skip to main content

Async wrapper for toon-parser - High-performance TOON format parser

Project description

toon-parser-async

Async wrapper for toon-parser - High-performance TOON format parser with asyncio support.

Installation

pip install toon-parser-async

This will automatically install toon-parser as a dependency.

Quick Start

import asyncio
from toon_parser_async import encode, decode, encode_batch, decode_batch

async def main():
    # Encode data
    data = {"name": "Alice", "age": 30}
    toon_str = await encode(data)
    print(toon_str)
    
    # Decode data
    decoded = await decode(toon_str)
    print(decoded)
    
    # Batch operations
    items = [{"id": i} for i in range(10)]
    encoded_items = await encode_batch(items)
    decoded_items = await decode_batch(encoded_items)

asyncio.run(main())

API

All functions are async and use asyncio.to_thread() to run the sync toon-parser functions in the thread pool:

  • async encode(data, delimiter=None, strict=None) - Encode Python data to TOON format
  • async decode(toon_str, delimiter=None, strict=None) - Decode TOON format to Python data
  • async dumps(data, **kwargs) - Alias for encode
  • async loads(toon_str, **kwargs) - Alias for decode
  • async encode_batch(data_list, **kwargs) - Encode multiple items concurrently
  • async decode_batch(toon_strs, **kwargs) - Decode multiple strings concurrently

Performance

toon-parser-async uses the high-performance toon-parser Rust library under the hood, which is 5.82x faster than other TOON implementations on average. The async wrapper adds minimal overhead while enabling concurrent I/O operations.

Credits

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

toon_parser_async-0.1.4-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file toon_parser_async-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for toon_parser_async-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 45f2c75bdacd354017b3c6a7a7f3ece79177aef6579f567eaf344e750be38c5a
MD5 1a35c59589ff724f88dbd3bd8c8ce4e6
BLAKE2b-256 ff2e1e2dff1e548f5fb1bdadfea12219a96cd495e2b5b2ae6859abdda114b864

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