A better TOML library for python implemented in rust.
Project description
rtoml
A better TOML library for python implemented in rust.
Why Use rtoml
- Correctness: rtoml is based on the widely used and very stable toml-rs library, it passes all the standard TOML tests as well as having 100% coverage on python code. Other TOML libraries for python I tried all failed to parse some valid TOML.
- Performance: see benchmarks - rtoml is much faster than pure Python TOML libraries.
Install
Requires python>=3.7
, binaries are available from pypi for linux, macos and windows,
see here.
pip install rtoml
If no binary is available on pypi for you system configuration; you'll need rust nightly and
setuptools-rust
installed before you can install rtoml.
Usage
load
def load(toml: Union[str, Path, TextIO]) -> Dict[str, Any]: ...
Parse TOML via a string or file and return a python dictionary. The toml
argument may be a str
,
Path
or file object from open()
.
loads
def loads(toml: str) -> Dict[str, Any]: ...
Parse a TOML string and return a python dictionary. (provided to match the interface of json
and similar libraries)
dumps
def dumps(obj: Any, *, pretty: bool = False) -> str: ...
Serialize a python object to TOML.
If pretty
is true, output has a more "pretty" format.
dump
def dump(obj: Any, file: Union[Path, TextIO], *, pretty: bool = False) -> int: ...
Serialize a python object to TOML and write it to a file. file
may be a Path
or file object from open()
.
If pretty
is true, output has a more "pretty" format.
Example
from datetime import datetime, timezone, timedelta
import rtoml
obj = {
'title': 'TOML Example',
'owner': {
'dob': datetime(1979, 5, 27, 7, 32, tzinfo=timezone(timedelta(hours=-8))),
'name': 'Tom Preston-Werner',
},
'database': {
'connection_max': 5000,
'enabled': True,
'ports': [8001, 8001, 8002],
'server': '192.168.1.1',
},
}
loaded_obj = rtoml.load("""\
# This is a TOML document.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates
[database]
server = "192.168.1.1"
ports = [8001, 8001, 8002]
connection_max = 5000
enabled = true
""")
assert loaded_obj == obj
assert rtoml.dumps(obj) == """\
title = "TOML Example"
[owner]
dob = 1979-05-27T07:32:00-08:00
name = "Tom Preston-Werner"
[database]
connection_max = 5000
enabled = true
server = "192.168.1.1"
ports = [8001, 8001, 8002]
"""
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for rtoml-0.7.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 177fd55dc5cd329f2fa41f3a6943fd3bc43c6e3b04ee6a46f8430414199a00f0 |
|
MD5 | f0f6c7a1ae02e9e032eff4d63685fe5d |
|
BLAKE2b-256 | e84d5a77bf492d6dcf8d2d335b432ca5df9315c3eebfdad755ab2808655fc244 |
Hashes for rtoml-0.7.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8c844fd0ac5b0b0cae121b46f6103fbcb15d4c786687a18cc5b0cc30f1f4007 |
|
MD5 | cfdc3a336fc52ac1460ba9c1708c8b0a |
|
BLAKE2b-256 | 86ba53d3c1ef83ecffc6bd3f2f2fa43ce6bab5554bdb6bb84ab6f0c471b4d918 |
Hashes for rtoml-0.7.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b83c53a854097395554e1392f1041789e8925019d4b12848d29727d7fd9d2d5c |
|
MD5 | 4d575385d6bcfa233aebd6ea423900d9 |
|
BLAKE2b-256 | 71e7e42ec4569c024343373bd38751f3e6c4ec0eea4666f7143289f197ed4b45 |
Hashes for rtoml-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1d8404f91dc6addfa70ebbfdb1ee1d7392d580677f2f43370e79548710d1302 |
|
MD5 | 97a07790d81d1ed413bb554629bb673a |
|
BLAKE2b-256 | fff75405f0fcc048d2599b7165c43a4c67ffd281c0e964dfd3f371b8fcc27335 |
Hashes for rtoml-0.7.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fee9dc92056c3dcd870d6727ea7e4d05b46175d4054bacd52df8d366291237b |
|
MD5 | 56e1b7a7769e9bee3566acae2932cc93 |
|
BLAKE2b-256 | 9004c62476f81cabff5d6d2f3d6c4fbc9b23e5f184e6b405fa6c034f51ff86a8 |
Hashes for rtoml-0.7.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fae1eee36fa08ab7590f492ee1ffbd94b18a07f4199515feb62e02d44eb61b81 |
|
MD5 | 532d4cb582a136e024946031fcb7219d |
|
BLAKE2b-256 | 7f74b7a91e687ceb18928b9b62209ff3ea8b6b3a0d3f2eba9e6c8cd44090245f |
Hashes for rtoml-0.7.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b765e4b940371df3668bd7f13be33f80fcd5c4e673f3eee9d74d637d6b34558 |
|
MD5 | baca80fa86edaaab6184c9ab782878a1 |
|
BLAKE2b-256 | f8f6da97e8f98ba76399ad13e46621e957cf1f3be8da77836a19d2c19a6a45fe |
Hashes for rtoml-0.7.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2abd34db201796e6b49cf16677829c86c0543f2399c9bd392bd3499daedf8d32 |
|
MD5 | d8cbb2ff2df2067487a5efa1e099acbd |
|
BLAKE2b-256 | 5b5348fc76f5581ebee3a850e4a2d0034fac2ef7d2f893f822ded5c76a089c17 |
Hashes for rtoml-0.7.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9f8a5d671cbed209e7a6801921fdd78186334f8c58bb9618d5782f483bbeebf |
|
MD5 | ba8e345d0b3f69c7df16f7dbfe9ecbbf |
|
BLAKE2b-256 | 9f030287636fbec8c2eef65cfa9513573300c4f01befbc6c08092af59ce78f83 |
Hashes for rtoml-0.7.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e41a0d63d6392d33761a2e67db6a8a9246c4c6f38d2b93c2e762d765a1d50070 |
|
MD5 | 2f919e261b4d801877d5c26e7d44b563 |
|
BLAKE2b-256 | 8ba3f2a46f127d2a5eb1d95569d48c7db5d6a58e8cae71b510ba8f2121ecdc98 |
Hashes for rtoml-0.7.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da9b6a3980a01102eb742b1e4efb45e35df0b34d0fcfa3ec19cc71cf2989ba0f |
|
MD5 | dde58cd62138ab6ecea9d353b8e2f73e |
|
BLAKE2b-256 | 6335bc37fb35b915136e67bdaeb7ae97268aaa929b0daa0b2b4446742b0e05b9 |
Hashes for rtoml-0.7.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81819b661f7429d468c305caf781e9aee715316a23898a0196cefc4a867a8483 |
|
MD5 | 3a62040821593afd6f06d25db2702290 |
|
BLAKE2b-256 | bdd75572a52ad22d2fc8aa1d4780fd1c2d48c846994295fd6223d8fb677cd9e2 |
Hashes for rtoml-0.7.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b59aa478a4bbf5481feb8a00d08e7d38e8d25139b851463c0474284ed1fdac32 |
|
MD5 | 3bcf8a12612686d244abfede1a32f894 |
|
BLAKE2b-256 | 73ca3fc18c323916c01fb3e3ae2a91e8c67f01c62d78b191483bbd98f18e8321 |
Hashes for rtoml-0.7.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 454e02542492c4458981ce57235a892e37cc6bf99e06bf30ddbd4029a78e6395 |
|
MD5 | 10e8e0f76dd495ca95dcec01632b0f01 |
|
BLAKE2b-256 | 60c5aca3de4495994c1f64a89bbbfbfcc84d91a52e05b978e62fd4450ccb8214 |
Hashes for rtoml-0.7.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf0c8f9b10f4da83a69cf249bc6b7d3ed7f1de6b4f84f548e8f2f9683eab9b8c |
|
MD5 | ace489f7ac71f613b195caf82d253fb6 |
|
BLAKE2b-256 | 8266dc240737d771db49098e6841548875a45362d5475d850ee097261c74731c |
Hashes for rtoml-0.7.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93600edc8d0be10b7f6532b580fa6ab31e7aa7673454a9e7569a116839fdf2d1 |
|
MD5 | 2b652d312e1b9108c056facc0d8a3592 |
|
BLAKE2b-256 | 053f9447fdb35a84356844b95d7b8f5acf695ec07f68e8fef183ce7987e4b887 |
Hashes for rtoml-0.7.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 866614518934a9e7ddf30f2a24922397c2aa0d7548dc100648c6bf4f82f9d2dd |
|
MD5 | 5268518f4ad72fb451f5983a30072a66 |
|
BLAKE2b-256 | 7b338dd1968d53ec9e55e4f8d683f3cb0fa7c1f0ac692c4ad24c732dbb4db8a1 |
Hashes for rtoml-0.7.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b27afda8c18e65ad98b39a977ef37742410b3a126c2ce7eb9c1abe001da349e2 |
|
MD5 | 9d7cf2f368b8cbc74b4909c6c4c07b42 |
|
BLAKE2b-256 | ef1200592ba276aaa16d02c318660cd24082b19286243648bae100a45b7c8b3d |
Hashes for rtoml-0.7.1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19b7f0d16718086dfc2c8f244d0f7254788343fb5ecee2a871bdf45efd3e679b |
|
MD5 | 578aec4341929b99967d540cbedbff7b |
|
BLAKE2b-256 | cd4f609a53edfc3b1cb4da7b9b39bb1f8a51824e3b675808acc7096b25cd3c23 |
Hashes for rtoml-0.7.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c48819b034813007d48aa1fbceb478d9b6dc4f8f277036082e7e98a1d97dff4 |
|
MD5 | c8126b5d830db02feb64cd796a131223 |
|
BLAKE2b-256 | 8b5ef6f33ccd6ef60c4ff1192f98b7c19968a55e309d2907b3b6e07789158d6d |
Hashes for rtoml-0.7.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80cf3ea694407bbdd13cd3beeb2e8a8394168b0e3164ec509aa3f29e84162ec1 |
|
MD5 | fb391ec6a206d11850ec7a6f92b99b1d |
|
BLAKE2b-256 | 0854c8653c7f4a18ca249177f63d1fd6626b0d7d8383fce0caeaee7ed99ad11e |
Hashes for rtoml-0.7.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3024de7114a23aac3cefef5286ff22f6686d0b167c6767d45ea3842e8ec91333 |
|
MD5 | a241f3356de518edf69c5ef2b54b4588 |
|
BLAKE2b-256 | 282788aa6f7b115cd9a526fcaac854bde242f2d8bcf327b19684e6408ca1af3e |