Srsly is a Python library providing modern, high-performance serialization utilities. It bundles optimized versions of popular serialization libraries (like ujson, msgpack, cloudpickle, and ruamel.yaml) into a single, standalone package, offering a consistent high-level API for handling JSON, JSONL, MessagePack, Pickle, and YAML data across different platforms and Python versions. It is actively maintained with frequent updates.
pip install srslyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `srsly` to write and read data in JSON and JSONL formats. It covers basic file operations using `srsly.write_json`, `srsly.read_json`, `srsly.write_jsonl`, and `srsly.read_jsonl`.
Upgrade to Python 3.6+ to use srsly v2.x. For Python 2.7, use srsly v1.x (which is no longer actively maintained).
Upgrade to srsly v1.0.7 (if on 1.x) or v2.4.7 (or newer) to include the patches for these vulnerabilities.
Ensure that if you are building srsly from source, your Cython version is 0.29.x. If using Cython 3, you might encounter build issues until srsly officially supports it. Binary wheels are not affected by this specific build-time dependency.
pip install srsly
Ensure the input data is valid JSON or JSON Lines format before attempting to load it.
Convert non-serializable objects to a compatible type (e.g., list for a set) or provide a custom 'default' function to srsly.json_dumps or srsly.msgpack_dumps.
Review and correct the YAML syntax and indentation in your input data.
No dependency data recorded yet.