Skip to main content

A python wrapper for toml++

Project description

pytomlpp

Build Status Conda Status TOML

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

Some points you may want to know before use:

  • Using tomlplusplus means that this module is fully compatible with TOML v1.0.0.
  • We convert toml structure to native python data structures (dict/list etc.) when parsing, this is more inline with what json module does.
  • The binding is using pybind11.
  • The project is tested using toml-test and pytest.

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 exisitng python TOML parser on the market but from my experience they are all purely implemented in python which is a bit slow.

In [1]: import pytomlpp                                                                                                                                                                                                                                                                                                  

In [2]: import toml                                                                                                                                                                                                                                                                                                      

In [3]: def run_parser(parser_func): 
   ...:     for i in range(1000): 
   ...:         parser_func('Cargo.toml') 
   ...:                                                                                                                                                                                                                                                                                                                  

In [4]: %timeit run_parser(pytomlpp.load)                                                                                                                                                                                                                                                                                
310 ms ± 56.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [5]: %timeit run_parser(toml.load)                                                                                                                                                                                                                                                                                    
3.5 s ± 162 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [6]: pytomlpp.lib_version                                                                                                                              
Out[6]: '1.3.2'

Installing

We recommand you to use conda to install this package:

conda install -c dorafmon pytomlpp

If you are not using conda then please install from source:

git clone git@github.com:bobfang1992/pytomlpp.git
cd pytomlpp
pip install .

Why not pypi?

Pypi has some rules on how to distribute pre-compiled binary for different platforms. I do not have enough experties in this area. I would love to see contribution to make this package avaliable on pypi.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pytomlpp-0.2.0-cp38-cp38-manylinux2010_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pytomlpp-0.2.0-cp38-cp38-manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

pytomlpp-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (126.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pytomlpp-0.2.0-cp37-cp37m-manylinux2010_x86_64.whl (1.4 MB view hashes)

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

pytomlpp-0.2.0-cp37-cp37m-manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

pytomlpp-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (124.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

pytomlpp-0.2.0-cp36-cp36m-manylinux2010_x86_64.whl (1.4 MB view hashes)

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

pytomlpp-0.2.0-cp36-cp36m-manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

pytomlpp-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl (124.9 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

pytomlpp-0.2.0-cp35-cp35m-manylinux2010_x86_64.whl (1.4 MB view hashes)

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

pytomlpp-0.2.0-cp35-cp35m-manylinux2010_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ i686

pytomlpp-0.2.0-cp35-cp35m-macosx_10_9_x86_64.whl (124.8 kB view hashes)

Uploaded CPython 3.5m macOS 10.9+ x86-64

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