Home

Awesome

pytomlpp

Build Status Conda Status PyPI version

This is an python wrapper for toml++ (https://marzer.github.io/tomlplusplus/).

Some points you may want to know before use:

Example

In [1]: import pytomlpp

In [2]: toml_string = 'hello = "世界"'

In [3]: pytomlpp.loads(toml_string)
Out[3]: {'hello': '世界'}

In [4]: type(_)
Out[4]: dict

In [6]: pytomlpp.dumps({"你好": "world"})
Out[6]: '"你好" = "world"'

Why bother?

There are some existing python TOML parsers on the market but from my experience they are implemented purely in python which is a bit slow.

Parsing data.toml 1000 times:
     rtoml:   0.540 s
  pytomlpp:   0.542 s ( 1.00x)
     tomli:   2.923 s ( 5.40x)
     qtoml:   8.748 s (16.18x)
   tomlkit:  51.608 s (95.49x)
      toml: Parsing failed. Likely not TOML 1.0.0-compliant.

Test it for yourself using the benchmark script.

Installing

We recommend you to use pip to install this package:

pip install pytomlpp

You can also use conda to install this package, on all common platforms & python versions. If you have an issue with a package from conda-forge, you can raise an issue on the feedstock

conda install -c conda-forge pytomlpp

You can also install from source:

git clone git@github.com:bobfang1992/pytomlpp.git --recurse-submodules=third_party/tomlplusplus --shallow-submodules
cd pytomlpp
pip install .

Alt