Skip to main content

A better TOML library for python implemented in rust.

Project description

rtoml

Actions Status Coverage pypi license

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 other TOML libraries for python.

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]) -> Any: ...

Parse TOML via a string or file and return a python object. The toml argument may be a str, Path or file object from open().

loads

def loads(toml: str) -> Any: ...

Parse a TOML string and return a python object. (provided to match the interface of json and similar libraries)

dumps

def dumps(obj: Any) -> str: ...

Serialize a python object to TOML.

dump

def dump(obj: Any, file: Union[Path, TextIO]) -> int: ...

Serialize a python object to TOML and write it to a file. file may be a Path or file object from open().

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtoml-0.3.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distributions

rtoml-0.3.0-cp38-cp38-win_amd64.whl (208.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

rtoml-0.3.0-cp38-cp38-manylinux2010_x86_64.whl (826.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

rtoml-0.3.0-cp38-cp38-manylinux2010_i686.whl (902.0 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

rtoml-0.3.0-cp38-cp38-manylinux1_x86_64.whl (826.5 kB view details)

Uploaded CPython 3.8

rtoml-0.3.0-cp38-cp38-manylinux1_i686.whl (902.0 kB view details)

Uploaded CPython 3.8

rtoml-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl (259.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

rtoml-0.3.0-cp37-cp37m-win_amd64.whl (208.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

rtoml-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl (826.6 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

rtoml-0.3.0-cp37-cp37m-manylinux2010_i686.whl (902.0 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

rtoml-0.3.0-cp37-cp37m-manylinux1_x86_64.whl (826.6 kB view details)

Uploaded CPython 3.7m

rtoml-0.3.0-cp37-cp37m-manylinux1_i686.whl (902.0 kB view details)

Uploaded CPython 3.7m

rtoml-0.3.0-cp37-cp37m-macosx_10_6_intel.whl (259.6 kB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

File details

Details for the file rtoml-0.3.0.tar.gz.

File metadata

  • Download URL: rtoml-0.3.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for rtoml-0.3.0.tar.gz
Algorithm Hash digest
SHA256 86410745d94496154054e8bdb7d7f7b472c5df6a2bff02ddae7fb12ac0773a3e
MD5 f7d2ccabcb23c1453de78ce20576142b
BLAKE2b-256 e94554a258c54db3b7a007c610c4b35709879289c35bb846da66da18e78b5351

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 208.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for rtoml-0.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9dce54af9c24b41cee793ef3d3f21770ae7bc4e3cbb12df006586bda46529473
MD5 e82bb2003488d84562fa1b37880c1234
BLAKE2b-256 8b793a211386040852744d5bb20e6d5037be240da15417425b3795799a84c3b4

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 826.5 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for rtoml-0.3.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8d3fbdee8a8231a2dcaaa892d541d4a30e48f201f91f5809a930b44b58380b3e
MD5 346c54a178a5e9df3ca463621f84bb81
BLAKE2b-256 8c7f055e9d54d0a2ca4fbd9e98dc2e24ef9e55570863f96341fc664e77910eda

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp38-cp38-manylinux2010_i686.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp38-cp38-manylinux2010_i686.whl
  • Upload date:
  • Size: 902.0 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for rtoml-0.3.0-cp38-cp38-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 46f57fdb87685cc1ea53fe113765a189a8ee07d0727d81138ffe49e5e4bca975
MD5 427b94ea8856cd4dca5899135d6614f9
BLAKE2b-256 c6e8990a49ebe04548f65d9d364a62b81b3671feb1b549ed65eb25afedd9d6c8

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 826.5 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for rtoml-0.3.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e400745823f328357ffee13338946584f632751a858cf24c531b9819f537ed8a
MD5 0b22d8ce9d541f4c04337d39bbdc36d1
BLAKE2b-256 4d0dc5aff6f29a768f067a090118ad7a1ba0e8c251ea2c94d90648254112048a

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp38-cp38-manylinux1_i686.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 902.0 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for rtoml-0.3.0-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0be3dfa86ab91aa8b2624a10a1233b73fb27bae5111059448063b35149665203
MD5 ec7f42fe689ab496c4e540e126607528
BLAKE2b-256 79fa1ee48c727f87b4e09e170ae59b5a0aee29042e276747daa2e1df57ecc3fa

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 259.6 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for rtoml-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2c88dbf01daa37114f0339dfb6cd37d1c5b7616bf21f2346a1d1e922a1b608c3
MD5 5689f26438ba36592a9b97c91096ca9d
BLAKE2b-256 0bfa765d9158bc2def323432bb0af794d8128ae97fb3e98f65991f90adb4b820

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 208.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for rtoml-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b679ea5be6319e1039cdf71b228f2d76044a57c71a8aaddcca81356808670d80
MD5 73d5413f33bb522c3476c42458c115d1
BLAKE2b-256 ee7c947a468ce6e4262f31a417ec0596ce18b1782b8fa009595ddf523fbbaeff

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 826.6 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for rtoml-0.3.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 0835ae55440b4f882e5ef1396aeb0e30170f5f15fc4009e7b91ea7e245d8ef94
MD5 8784a3815b6cb357025a30119a7c9322
BLAKE2b-256 46ca5da4d1559276852c9ea65639af177c63e35fbc027891a14b332dfdcc9ba5

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp37-cp37m-manylinux2010_i686.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp37-cp37m-manylinux2010_i686.whl
  • Upload date:
  • Size: 902.0 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for rtoml-0.3.0-cp37-cp37m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 32f76620a10b6f326733724ca30288d7ff5bc47d32378c46d57789acc6f74064
MD5 20f2a9fd7a65c822932b3335d30842df
BLAKE2b-256 165518797b191d9cd62a945aaef8fdcd898a4c4f5776edd6a2ec50820774c98f

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 826.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for rtoml-0.3.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 26eafc21759f26c7f8479fa93f81e934ddf731ff5754f52d2a37199096c677bf
MD5 097e1905c5bdece20ea1b17827630a92
BLAKE2b-256 6245636cc425272a2c951bb718da31f2105413d6b408165801517714967e78fc

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 902.0 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for rtoml-0.3.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 5a5d900a351249f87f9c2a73483533be38f4b7d127f75a2be8212e1a486f201d
MD5 241b700be38057cbbdd7d8295aa9022e
BLAKE2b-256 d49f302348d59db4ef34f592f173b1e36a0b857de85734c1b8cec90426f27410

See more details on using hashes here.

Provenance

File details

Details for the file rtoml-0.3.0-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: rtoml-0.3.0-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 259.6 kB
  • Tags: CPython 3.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for rtoml-0.3.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 628aad51387b66c0482b9eeaa43a1df8df62b6ba8d034904602544625105737f
MD5 e093cfcca6110d07e50c35d02271e782
BLAKE2b-256 557fcb9a5d9a08693faa3d942cf1b76f578a4e8ab03f651321b1d82ce3b2223d

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page