{"id":5418,"library":"pysimdjson","title":"pysimdjson","description":"pysimdjson provides high-performance Python bindings for the simdjson C++ library, a SIMD-accelerated JSON parser. It offers both a compatibility API similar to Python's built-in `json` module and a native API for significantly faster parsing, especially when only parts of a JSON document are needed. The library is actively maintained, with the current version being 7.0.2.","status":"active","version":"7.0.2","language":"en","source_language":"en","source_url":"https://github.com/TkTech/pysimdjson","tags":["json","simdjson","parser","performance","bindings"],"install":[{"cmd":"pip install pysimdjson","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required Python interpreter version.","package":"python","version":">=3.9"},{"reason":"Required for building from source if pre-compiled binary wheels are not available for your platform.","package":"C++11-capable compiler","optional":true}],"imports":[{"note":"The native, high-performance API for parsing documents.","symbol":"Parser","correct":"from pysimdjson import Parser"},{"note":"For a `json` module compatible experience, though the native API with `Parser` is recommended for performance.","symbol":"loads","correct":"from pysimdjson import loads"}],"quickstart":{"code":"from pysimdjson import Parser\n\njson_data = b'{\"name\": \"Alice\", \"age\": 30, \"city\": \"New York\", \"details\": {\"occupation\": \"Engineer\", \"hobbies\": [\"reading\", \"hiking\"]}}'\n\n# Using the native Parser API for performance and partial loading\nparser = Parser()\ntry:\n    # Parsing bytes is generally fastest\n    doc = parser.parse(json_data)\n\n    # Accessing elements without fully materializing the document\n    name = doc['name'].as_str()\n    age = doc['age'].as_int()\n    occupation = doc['details']['occupation'].as_str()\n    first_hobby = doc['details']['hobbies'][0].as_str()\n\n    print(f\"Name: {name}, Age: {age}\")\n    print(f\"Occupation: {occupation}, First Hobby: {first_hobby}\")\n\n    # Convert a subtree to a Python object if needed\n    details_dict = doc['details'].as_dict()\n    print(f\"Details as dict: {details_dict}\")\n\nexcept RuntimeError as e:\n    print(f\"Error during parsing or access: {e}\")\n\n# For simple full document loading, compatible with json.loads\nfrom pysimdjson import loads\nfull_python_obj = loads(json_data)\nprint(f\"Full Python object (loads): {full_python_obj}\")\n","lang":"python","description":"This quickstart demonstrates both the high-performance native API using `pysimdjson.Parser` for selective data extraction and the `pysimdjson.loads` function for full document parsing, similar to the standard `json` module. The native API is generally preferred for large documents to avoid unnecessary object materialization."},"warnings":[{"fix":"Upgrade your Python interpreter to version 3.9 or higher.","message":"Python 3.5 and 3.6 support has been removed in prior major releases. Current versions (>=7.0.0) require Python 3.9 or newer. Ensure your environment meets the Python version requirement.","severity":"breaking","affected_versions":"<7.0.0 (Python 3.5, 3.6)"},{"fix":"Utilize `pysimdjson.Parser().parse(data)` and navigate the `doc` object using dictionary-like or list-like access, then convert to Python primitives (e.g., `.as_str()`, `.as_int()`, `.as_dict()`) only for the data you need.","message":"For optimal performance, especially with large JSON documents, avoid fully materializing the entire document into Python objects. Use the native `Parser` API with methods like `at_pointer()` or direct proxy access (e.g., `doc['key']`) to extract only the necessary parts.","severity":"gotcha","affected_versions":"All"},{"fix":"Allow previously created `Object` and `Array` proxy objects to go out of scope or explicitly delete them before reusing a `Parser` instance for a new document. Consider creating a new `Parser` instance for each document if managing proxy lifetimes is complex.","message":"When reusing a `pysimdjson.Parser` instance, ensure that no `Object` or `Array` proxies from a previously parsed document are still in scope. Calling `parse()` or `load()` on a parser while old proxies exist may lead to a `RuntimeError` due to memory management conflicts.","severity":"gotcha","affected_versions":"All"},{"fix":"Always provide JSON data as `bytes` (e.g., `b'{ \"key\": \"value\" }'`) to the parser for best performance and to avoid encoding issues.","message":"pysimdjson primarily operates on `bytes` and assumes UTF-8 encoding. It does not provide options to specify alternative encodings, unlike the standard `json` module. Providing `str` will be slower due to internal encoding.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}