Giter VIP home page Giter VIP logo

pytomlpp's Introduction

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:

  • Using toml++ 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.
  • We support all major platforms (Linux, Mac OSX and Windows), for both CPython and Pypy and all recent Python versions. You just need to pip install and we have a pre-compiled binaries ready. No need to play with clang, cmake or any C++ toolchains.

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 [email protected]:bobfang1992/pytomlpp.git --recurse-submodules=third_party/tomlplusplus --shallow-submodules
cd pytomlpp
pip install .

Alt

pytomlpp's People

Contributors

bobfang1992 avatar epicwink avatar backist avatar chaitan94 avatar marzer avatar h-vetinari avatar neutrinoceros avatar mattip avatar hukkinj1 avatar viicos avatar ioistired avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.