Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Aug 20, 2023. It is now read-only.
/TinyMPPublic archive

A MessagePack-based storage extension to tinydb using thehttp://msgpack.org

License

NotificationsYou must be signed in to change notification settings

alshapton/TinyMP

Repository files navigation

artwork/tinymplogo.png

https://travis-ci.org/alshapton/TinyMP.svg?branch=master

TinyMP is a storage backend for TinyDBhttps://github.com/msiemens/tinydb which is based around the MessagePack compressed JSON format (https://msgpack.org/index.html)

Syntax :

TinyMP extends the syntax of thetinydb class using one of the optionalkwargs as follows:

Values for**kwargs
ValueEffect
storage=MsgPackStorageDefault option, will use theMsgPack library
storage=MsgPackStorage,Lib='msgpack'Will use theMsgPack library
storage=MsgPackStorage,Lib='umsgpack'Will use theU-MsgPack Library

Example Usage:

fromtinydbimportTinyDB,Queryfromtinympimport*db=TinyDB('data.msg',storage=MsgPackStorage)defdbins():db.insert({'type':'apple','count':7})dbins()

As you can see, it's a simple drop-in replacement for any storage engineand it can be nested and cached. Don't forget, you will need to install as a minimum,themsgpack-python library usingpip install msgpack-python and theU-MsgPacklibrary fromhttps://github.com/vsergeev/u-msgpack-python in order to use that option.

Example Usage using alternative MessagePack Library:

fromtinydbimportTinyDB,Queryfromtinympimport*db=TinyDB('data.msg',storage=MsgPackStorage,Lib='umsgpack')defdbins():db.insert({'type':'apple','count':7})dbins()

As you can see, it's a simple drop-in replacement for any storage engineand it can be nested and cached.

Why would I use this?

Looking at the statistics below, it's apparent that compared to the "standard"JSON Storage mechanism, MessagePack isn't as quick, however, the filesizes ondisc are smaller - consider the table below, with 1,000 JSON documents ofminute size - clearly, the MessagePack compressed format is smaller thanthe JSON format. Whether you choose the default MsgPack library, which ismarginally slower than the U-MsgPack library (at the cost of a small increasein storage footprint with U-MsgPack) is dependent on your use case.

Timings (seconds)
FormatRun 1Run 2Run 3FileSize
JSON Write:2.1472.0112.04037.0 Kb
MsgPack Write:9.5629.7329.71621.1 Kb
U-MsgPack Write:9.3549.0668.94924.1 Kb

Changes

  • Version 1.0.0-Beta5 - XX/XX/XXXX
    • Added PiPy compatibility
    • PEP-8 Compliant code style
  • Version 1.0.0-Beta4 - 11/26/2017
    • Added descriptions of benchmarking and tidied up repo
    • Further added information to README about usage
  • Version 1.0.0-Beta3 - 11/24/2017
    • Added support for u-msgpack-python alternative msgpack library
  • Version 1.0.0-Beta2 - 11/21/2017
    • Fixed Testing issues
  • Version 1.0.0-Beta - 11/19/2017
    • Tidied up repo ready for Beta release
  • Version 0.2.0 - 11/18/2017
    • Tidied up repo
    • Added initial benchmarking and example
    • Added Github Community files.
  • Version 0.1 - 11/13/2017
    • Initial Release.

References:


[8]ページ先頭

©2009-2025 Movatter.jp