{"id":4752,"library":"rtoml","title":"rtoml: Fast TOML Library for Python (Rust Implemented)","description":"rtoml is a high-performance Python library for parsing and serializing TOML, implemented in Rust. It emphasizes correctness, speed, and flexible handling of `None` values, passing all standard TOML tests. It currently requires Python 3.10 or newer and is actively maintained with frequent updates.","status":"active","version":"0.13.0","language":"en","source_language":"en","source_url":"https://github.com/samuelcolvin/rtoml","tags":["toml","serialization","parsing","rust","performance"],"install":[{"cmd":"pip install rtoml","lang":"bash","label":"Install rtoml"}],"dependencies":[{"reason":"Required for installation if pre-built wheels are not available for your system configuration.","package":"rust","optional":true}],"imports":[{"symbol":"load","correct":"import rtoml\nconfig = rtoml.load('path/to/config.toml')"},{"symbol":"loads","correct":"import rtoml\nconfig = rtoml.loads('[section]\\nkey = \"value\"')"},{"symbol":"dump","correct":"import rtoml\nwith open('path/to/config.toml', 'w') as f:\n    rtoml.dump(data, f)"},{"symbol":"dumps","correct":"import rtoml\ntoml_string = rtoml.dumps(data)"}],"quickstart":{"code":"import rtoml\n\n# Define a Python object\nobj = {\n    'title': 'TOML Example',\n    'owner': {\n        'name': 'Tom Preston-Werner',\n    },\n    'database': {\n        'server': '192.168.1.1',\n        'ports': [8001, 8001, 8002],\n        'connection_max': 5000,\n        'enabled': True,\n        'option_none': None # Example with None\n    },\n}\n\n# Serialize Python object to TOML string\ntoml_string = rtoml.dumps(obj, pretty=True)\nprint(\"Generated TOML:\\n\", toml_string)\n\n# Load TOML string back into a Python object\nloaded_obj = rtoml.loads(toml_string)\nprint(\"\\nLoaded object:\\n\", loaded_obj)\n\n# Verify round-trip (Note: None handling defaults differ)\n# For exact match with None, dumps(none_value=None) or loads(none_value='null') might be needed\nassert loaded_obj['database']['option_none'] is None\nassert loaded_obj['database']['enabled'] == obj['database']['enabled']","lang":"python","description":"This quickstart demonstrates how to serialize a Python dictionary to a TOML string using `rtoml.dumps` and then parse it back using `rtoml.loads`. It also highlights the default behavior of `None` values."},"warnings":[{"fix":"Upgrade your Python environment to version 3.10 or newer, as required by `rtoml`.","message":"Python 3.8 support was dropped in `rtoml` version `0.12.0`.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Upgrade your Python environment to version 3.10 or newer, as required by `rtoml`.","message":"Python 3.7 support was dropped in `rtoml` version `0.10.0`.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"For consistent `None` handling, explicitly set the `none_value` parameter. For example, use `rtoml.dumps(..., none_value=None)` to omit `None` values from the output, or `rtoml.loads(..., none_value='null')` to parse a specific string (like `null`) into Python's `None`.","message":"The default handling of `None` values differs between `rtoml.loads` and `rtoml.dumps`. By default, `loads` ignores TOML keys with `none_value` (which is `None` by default), effectively treating them as if they don't exist in the input. Conversely, `dumps` will serialize Python `None` as the string `\"null\"` by default (`none_value=\"null\"`). This can lead to unexpected behavior during round-tripping if not explicitly configured.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}