{"id":1135,"library":"srsly","title":"Srsly: High-Performance Python Serialization Utilities","description":"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.","status":"active","version":"2.5.3","language":"python","source_language":"en","source_url":"https://github.com/explosion/srsly","tags":["serialization","json","msgpack","pickle","yaml","performance"],"install":[{"cmd":"pip install srsly","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"json_loads","correct":"import srsly\ndata = srsly.json_loads('{\"key\": \"value\"}')"},{"symbol":"read_json","correct":"import srsly\ndata = srsly.read_json('path/to/file.json')"},{"symbol":"write_json","correct":"import srsly\nsrsly.write_json('path/to/file.json', {'key': 'value'})"},{"symbol":"msgpack_dumps","correct":"import srsly\nmsg_bytes = srsly.msgpack_dumps({'key': 'value'})"}],"quickstart":{"code":"import srsly\nimport os\n\n# Example with JSON\nfile_path = 'example.json'\ndata = {\"name\": \"Alice\", \"age\": 30, \"isStudent\": False}\n\n# Write JSON to a file\nsrsly.write_json(file_path, data)\nprint(f\"Data written to {file_path}\")\n\n# Read JSON from a file\nread_data = srsly.read_json(file_path)\nprint(f\"Data read from {file_path}: {read_data}\")\n\n# Clean up\nos.remove(file_path)\n\n# Example with JSONL (newline-delimited JSON)\njsonl_path = 'example.jsonl'\nlines = [{\"id\": 1, \"text\": \"First line\"}, {\"id\": 2, \"text\": \"Second line\"}]\n\n# Write JSONL to a file\nsrsly.write_jsonl(jsonl_path, lines)\nprint(f\"Data written to {jsonl_path}\")\n\n# Read JSONL from a file\nread_lines = list(srsly.read_jsonl(jsonl_path))\nprint(f\"Data read from {jsonl_path}: {read_lines}\")\n\n# Clean up\nos.remove(jsonl_path)","lang":"python","description":"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`."},"warnings":[{"fix":"Upgrade to Python 3.6+ to use srsly v2.x. For Python 2.7, use srsly v1.x (which is no longer actively maintained).","message":"Srsly v2.x (and later) dropped support for Python 2.x. Users migrating from v1.x must ensure their environment is Python 3.6 or newer.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade to srsly v1.0.7 (if on 1.x) or v2.4.7 (or newer) to include the patches for these vulnerabilities.","message":"Versions prior to v1.0.7 and early v2.x contained security vulnerabilities (CVE-2022-31116, CVE-2021-4595) related to incorrect handling of surrogate pair characters and buffer overflows in the vendored `ujson` component.","severity":"gotcha","affected_versions":"<1.0.7, <2.4.7"},{"fix":"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.","message":"Srsly v2.4.7 introduced a restriction to Cython 0.29.x due to incompatibilities with Cython 3. This primarily affects users who compile srsly from source or have Cython 3 installed in their environment.","severity":"gotcha","affected_versions":">=2.4.7"}],"env_vars":null,"search_vec":"'across':55 'activ':63 'api':45 'bundl':21 'cloudpickl':31 'consist':41 'data':54 'differ':56 'frequent':66 'handl':47 'high':3,16,43 'high-level':42 'high-perform':2,15 'json':48,69 'jsonl':49 'level':44 'librari':12,27 'like':28 'maintain':64 'messagepack':50 'modern':14 'msgpack':30,70 'offer':39 'optim':22 'packag':38 'perform':4,17,73 'pickl':51,71 'platform':57 'popular':25 'provid':13 'python':5,11,59 'ruamel.yaml':33 'serial':6,18,26,68 'singl':36 'srsli':1,8 'standalon':37 'ujson':29 'updat':67 'util':7,19 'version':23,60 'yaml':53,72","created_at":"2026-04-05T13:07:12.061407+00:00","updated_at":"2026-04-16T22:17:18.302423+00:00","problems":[{"fix":"pip install srsly","cause":"The srsly library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'srsly'"},{"fix":"Ensure the input data is valid JSON or JSON Lines format before attempting to load it.","cause":"This error occurs when trying to parse an invalid, empty, or malformed JSON or JSONL string/file using srsly's JSON functions.","error":"json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"},{"fix":"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.","cause":"You are attempting to serialize a Python object (like a set or a custom class instance) that is not natively representable in JSON or MessagePack without providing a custom encoder.","error":"TypeError: Object of type set is not JSON serializable"},{"fix":"Review and correct the YAML syntax and indentation in your input data.","cause":"The input YAML string or file contains syntax errors, incorrect indentation, or is malformed, which prevents srsly's underlying YAML parser from processing it.","error":"ruamel.yaml.scanner.ScannerError: while scanning a block scalar"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.5.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/explosion/srsly","docs":null,"changelog":null,"pypi":"https://pypi.org/project/srsly/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}