Skip to main content

Async wrapper for toon-parser - Fast TOON format parser

Project description

toon-parser-async

Async wrapper for toon-parser - Fast 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)  # name:Alice|age:30
    
    # Decode data
    decoded = await decode(toon_str)
    print(decoded)  # {'name': 'Alice', 'age': 30}
    
    # 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.3-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for toon_parser_async-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 32921fb6c171b9c425da03a474cc16aede9360173d4d65c5c85079fbd6d1c95e
MD5 54b93878f9154445a54db40ad6475fb7
BLAKE2b-256 b0117643ac423a1b23efb6a7d5353984186c69af9f66ab1f64a31b4f0ed0894d

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