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.8.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d93a2e9197ecda83765ed14661a933abf616de37442a8705ef6f1a897fa3299 |
|
MD5 | 0fbf58a181db87846e9c81ee66084f24 |
|
BLAKE2b-256 | a7f952cf30a3310b9f0f8c273630f779be4e653603ef649bfa11a709608ee11b |
Hashes for rtoml-0.8.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9708df41c348fa570cfaa9d62bfb46d14a1e7f3fe08203dab55fa22c1cd81a9f |
|
MD5 | 3a399620b7485bc9c2651ceca31226ce |
|
BLAKE2b-256 | 2c7ffa8132eb1d47edab7af212e0b1f846c60418fb082e5c0905a633d1ad1355 |
Hashes for rtoml-0.8.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9cbd99d158e440951f851613ce3b6f29c201676124900876937ebf65307c3a1 |
|
MD5 | 261edde39cc317e8917ae6db4f76dc4b |
|
BLAKE2b-256 | 05d216f257c42c90f6166e9d09358c680cdae2f98479432b447528f4cc9cbc6e |
Hashes for rtoml-0.8.0-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7fca6d6cd6182cf758c3b4b8554f6d548f9d921ba1cb91adb4aca779010cdfa |
|
MD5 | e0c22861a2017e86515811bc57ec352d |
|
BLAKE2b-256 | df98aca7294ce91d9e5d1eed2b2633fc5b0430e9cf7cfcb477d7fad8825da70c |
Hashes for rtoml-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87da140716797198c9d011896c2b092ea5662d48d94059e705504b37131255a8 |
|
MD5 | 78a5df40a02dbd9e6b467e809bbb9de1 |
|
BLAKE2b-256 | df63ca1389f49ae5bcce3bf7d0c66f43792004c460ddb94517b74dd92acab869 |
Hashes for rtoml-0.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b11aefaaeab294bb98b3afa3a47d3f898378904e6a2b62fa1eca48caf1cfe878 |
|
MD5 | b24e3ebe7c93491a4d2e1e6dc3d87e90 |
|
BLAKE2b-256 | a761021864f773692f8b9442326505270cb0addb1ed2f7764a56e520c91d74d8 |
Hashes for rtoml-0.8.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b77916b8d0cea069b0b7b59eb40a7948fa2289eb7938546749b801290785632a |
|
MD5 | 1abcf93093c254b438cc07fb4ea3cc92 |
|
BLAKE2b-256 | 10e2d7cda797040f6a30dc94205716d2670e641b76ed24e1834ee6a289123c58 |
Hashes for rtoml-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 715bf814144f47306752b0ddf0965a1cf2e36410c3edc05fafe1363ba57fa2b6 |
|
MD5 | 3e05da4bef298c468a28ce3dcfb92b7d |
|
BLAKE2b-256 | 85163b73e37b448f0b56b6a7ce72f7cceb24b2d47011834a28c56c5a619f14b0 |
Hashes for rtoml-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e924ae37aeafd60d09b888ea30ae18bceac5086689216ab3ae16dd93692202a9 |
|
MD5 | e8250daecf0427947f0702558ef4e23a |
|
BLAKE2b-256 | 350817a41bfe911de3f25ee1a14a5ca795d39e1abeafa0c624da671429576713 |
Hashes for rtoml-0.8.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 333e5e1fc257b1302f589b662fd2405ec4b3b68a032e125011bcf86ea52b19eb |
|
MD5 | 5a2b74fcfbbb3cc32b4d7965cb15108e |
|
BLAKE2b-256 | 8d70133dd4a81b2d13c6ad90c2d1eef340823c1a45c4016ed604d75f15f99fc6 |
Hashes for rtoml-0.8.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88a2187059be67a94e59519a91785f43db3159f2963ea8e15c31808a95b58c9f |
|
MD5 | 97993ff994dd1daa9afa5b77c5bb862d |
|
BLAKE2b-256 | 583027a17f8480f97ae04d577611d4e4e49346e731f74c323f0a51a49bb97d2f |
Hashes for rtoml-0.8.0-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ce59d9e077030a2bfc915ebb872d15532e61e57d967075ab978b76b933b9634 |
|
MD5 | 9da44296b737ec743a0e4071fd0e9ad2 |
|
BLAKE2b-256 | e3c93932dd05cae6d3cf66746f1229bdb50121192160931632aad3b5824b136d |
Hashes for rtoml-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9de660acc172db507321498275c8c8f052c6d3261331eb5aa964447bfecc90d1 |
|
MD5 | ad79a58986a34a488dfbb4dbe7287aae |
|
BLAKE2b-256 | a6f3fa438f171a4735997bd1505cf702d78468f777c47d604a499ac48fdf67b0 |
Hashes for rtoml-0.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f84b83a852ac8f8efca56490cd21eb53c55a116dd2485658f0ced2ee99e0b09f |
|
MD5 | 34ad04f5e52d689f76d2482e6bbaa794 |
|
BLAKE2b-256 | 93d87988aef5d32c9e0c00adb135c64969cd49d6c1baadc232512fafff2c96f7 |
Hashes for rtoml-0.8.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccc9fdd7064b1c8a990548956e27a3217c7a692e8bae222af8cdb3d0750dddf6 |
|
MD5 | 401d8921bb850e963d5af0f7e72fbcb5 |
|
BLAKE2b-256 | ca6e92e3f4b984b8fa7dc1e7907a948a68323c11621606b49ac39f7b7d238046 |
Hashes for rtoml-0.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a42c8faf9d7ea40a86ac8cb73d0e485467d4702fcc3b763276a046d9b6cd738e |
|
MD5 | 3762b3319a820fc8222b4a1f3b87be87 |
|
BLAKE2b-256 | dd515212d13ae4af1e789f50ff008d28b3bc94a2333a00f9657cfadc162bc8da |
Hashes for rtoml-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10d0f771558b8f8c0940e517f089cbea5f1ddfa8d684c176ac6c3a1797b50f19 |
|
MD5 | f74fca8b0e856f7d817c90b6cd4efd37 |
|
BLAKE2b-256 | 41dd4d03bc565e2d119c8cb2b7108a123274c85f9d5bf433102af1b695620871 |
Hashes for rtoml-0.8.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cc362b02d586721ec3b24cf1f6e9da0223fc2009dfa5b49b929e7d2c6fbaaf7 |
|
MD5 | 3fcdda84913014214b83ae99807f3e53 |
|
BLAKE2b-256 | 4a2acd37ac3c2717dfcd80226fdc4e7945a9398f4fe03cb2b34ee8f2632326ed |
Hashes for rtoml-0.8.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3773957d1a67d5620d64f73e855fd81de01fac5aff14d643cb5821854633c6d4 |
|
MD5 | 6938d693774f285dad39a641a0dd4d87 |
|
BLAKE2b-256 | a9c8c7a7e0660a1325c094ffc0d632665f9a0234d4bae3e02d15ffade0930cf8 |
Hashes for rtoml-0.8.0-cp38-cp38-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 617b57d9254c83d09646b8f6062a7da066c23b1999a63788f894a16707b710a7 |
|
MD5 | 92c853ba4cbac9f3d2b67d809479a8db |
|
BLAKE2b-256 | e0fca89cce365e6ba4ed18f6a56d1b15170a67eaf9b647836d324dcc7f68bc1b |
Hashes for rtoml-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5502507da47e142013e316133eaa0c0312c351aed9c02e51104dd9fc725b0925 |
|
MD5 | 1876d4f05da107f42e6956159e1b5730 |
|
BLAKE2b-256 | cfe97fc261b720a7c5ca561ef539380b9db9123c3e46f1a8edb029c9ec921934 |
Hashes for rtoml-0.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbfa5ae5b88991f88a8a8f06aeb572f7d5ec4811ee101ba90493754be3df677 |
|
MD5 | 2d528441b4fc33a63a567330f0027033 |
|
BLAKE2b-256 | b42ab37c492e7ea1582571c60a1f3e83d03760af998307e82607556f4ee6e5a6 |
Hashes for rtoml-0.8.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97fc53d7bb277ef379c919a5972e5faa403c7d41951c0e6fd57e00ad470ea992 |
|
MD5 | 3d8c6906e053bfc5ce0dfb6e558b8ab3 |
|
BLAKE2b-256 | 1441cfd8b82ca7b5133a3031e2c1164d0f656e9977bbdc2e1fbc49597c8e16aa |
Hashes for rtoml-0.8.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77173831317fc493752ddcc3c4ce20d6c322bbffbe4bcb3131a78fc6ca63a8a9 |
|
MD5 | f823bc20eda4deab79f6bd350aabc1c5 |
|
BLAKE2b-256 | 19660f3dd1b983eb5c55fb3f1ba7631e7ee51b3abdd1a9d78faae48cecaeaade |
Hashes for rtoml-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71a6ed08313755891a8341007892f4738e624a25f757136deea7a1c75862254e |
|
MD5 | 23639f7bf9275fba62df943222179366 |
|
BLAKE2b-256 | 4b636e5ed59244592842fb0663b3946ad6884a40c9dbb112283aced8667cd9ac |
Hashes for rtoml-0.8.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eea2ed0d724df91b230c89653a021fc0e22b1353d9a567d166093104cbe8e0c |
|
MD5 | ae1644c80aff34ba3b70209750421a44 |
|
BLAKE2b-256 | 1d8680d07aa19a500f8be78f1b00545c192cf2cd40ea91550d2409692e9b3460 |
Hashes for rtoml-0.8.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ce8bb6ea93ce1ce2de7a48bed47a290fcf6adf8d427768397512f4d9a107461 |
|
MD5 | b81bc7bfbe9de0ac6e5bbdd7b391f416 |
|
BLAKE2b-256 | ce40f0e0190e074ad27d26dbb72df308a7891be0bc51da9374ebb3866968b4c4 |
Hashes for rtoml-0.8.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2883cd30caac29c8f00dd8c7f20ee7cade778aba1413bea3c8e0fa6013581c9c |
|
MD5 | f10d23d50c8b3959f7d55e4829dab57f |
|
BLAKE2b-256 | 97175f285041cf71e5d55acde7536e460b7f4d5b489230066879c36d89742941 |
Hashes for rtoml-0.8.0-cp37-cp37m-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7846ed05136de9ec60f5ee5bb6a53c640f7e0504bd9ec3586016cb6cf36ea2b |
|
MD5 | 9081124966ec7e0207217b251d4abd4f |
|
BLAKE2b-256 | 1927a82f2bf0c86c656244b00432fd10dd2e987406000aa5c681a6f894643852 |
Hashes for rtoml-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d0f46641b4ac2e6934801d29c6c4c6f2bda017b34482aeb8f8170b977a60b17 |
|
MD5 | 3c0b30563d34d6c761244069b09f5762 |
|
BLAKE2b-256 | d7c669f87ecf66e778cc436157833c7d4600d651f0f409b6d8a33e923233cf26 |
Hashes for rtoml-0.8.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc6d82e5a28fffd3910a54d511ba7adc66f668b0c25d0ee75685aeb24ce4a730 |
|
MD5 | cf3580a2387d44d6ff30d7c877b3ff39 |
|
BLAKE2b-256 | 01de5ec24bdfed7a0b222479659a198adba8581bc2e7e7864af8650d9747a1a6 |
Hashes for rtoml-0.8.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb2a996587e39359ec1b638fa74d1247b7adebe4f804d03d1c681c064b0ae24c |
|
MD5 | 36e4ba1cb360146632b7d9f4b7ce4497 |
|
BLAKE2b-256 | 2d68e6ad54c18aaf0b299e28aab5a8e06a849e48b048634e3f812327ef7ffceb |
Hashes for rtoml-0.8.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f494155b5321718d3e9afecf94c0ca02bba03fbae7ec1922ab14543694c1603 |
|
MD5 | d1de3c602efdf9510740d43703e1affa |
|
BLAKE2b-256 | 145b744ec9c9b2d831ed830a84a432e646f2d12306f153d2fc7a84ac71fb3434 |