All Projects → dogtopus → minipb

dogtopus / minipb

Licence: BSD-3-Clause license
Mini Protobuf {,de}serializer

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to minipb

neofs-api-go
NeoFS API Golang repository contains implementation of core NeoFS structures that can be used for integration with NeoFS.
Stars: ✭ 14 (-58.82%)
Mutual labels:  protobuf
grphp
PHP gRPC Framework
Stars: ✭ 19 (-44.12%)
Mutual labels:  protobuf
gosproto
基于云风的sproto二进制标准上的描述文件及代码生成工具
Stars: ✭ 52 (+52.94%)
Mutual labels:  protobuf
qtprotobuf
Protobuf generator and bindings for Qt framework
Stars: ✭ 138 (+305.88%)
Mutual labels:  protobuf
protobuf-tools
Latest version of protobuf and dozen of plugins. All in a small Docker image
Stars: ✭ 19 (-44.12%)
Mutual labels:  protobuf
CSGO-Item-Floats-From-Inspect-Links
cuz bored as fuck, how to get the item floats from inspect links aka the market float "method"
Stars: ✭ 53 (+55.88%)
Mutual labels:  protobuf
protolua
C++ implement encode, decode Protocol Buffers for Lua without code generation
Stars: ✭ 117 (+244.12%)
Mutual labels:  protobuf
protocol
The schemas for the Harmony protocol
Stars: ✭ 16 (-52.94%)
Mutual labels:  protobuf
tilegrinder
♻️ A node.js GIS helper library for easy alteration of Vector Tiles in an MBTiles container
Stars: ✭ 64 (+88.24%)
Mutual labels:  protobuf
bloomrpc-mock
Toolset library for working with GRPC mocks
Stars: ✭ 25 (-26.47%)
Mutual labels:  protobuf
protoc-plugin
A protoc compiler plugin for Clojure applications
Stars: ✭ 28 (-17.65%)
Mutual labels:  protobuf
protoactor-go
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 4,138 (+12070.59%)
Mutual labels:  protobuf
twjitm-core
采用Netty信息加载实现长连接实时通讯系统,客户端可以值任何场景,支持实时http通讯、webSocket通讯、tcp协议通讯、和udp协议通讯、广播协议等 通过http协议,rpc协议。 采用自定义网络数据包结构, 实现自定义网络栈。
Stars: ✭ 98 (+188.24%)
Mutual labels:  protobuf
compatip
A simple tool to ensure compatibility between microservices
Stars: ✭ 13 (-61.76%)
Mutual labels:  protobuf
deprecated-pokemongo-game-master
⚠️ DEPRECATED - LOOK README ⚠️ This repository is collection of the decoded GAME_MASTER-protobuf files
Stars: ✭ 38 (+11.76%)
Mutual labels:  protobuf
goprotoc
Library for writing protoc plugins in Go; also includes a pure-Go protoc replacement
Stars: ✭ 73 (+114.71%)
Mutual labels:  protobuf
grpc-jwt-spring-boot-starter
Spring boot starter for gRPC framework with JWT authorization
Stars: ✭ 24 (-29.41%)
Mutual labels:  protobuf
modern-api-management
A modern approach to manage APIs effectively using Protobuf
Stars: ✭ 36 (+5.88%)
Mutual labels:  protobuf
protostuff-example
Experimenting protostuff
Stars: ✭ 13 (-61.76%)
Mutual labels:  protobuf
sisyphus
Sisyphus is the way how we provide backend services.
Stars: ✭ 59 (+73.53%)
Mutual labels:  protobuf

MiniPB

Mini Protobuf library in pure Python.

Python package

Features

  • Pure Python.
  • Feature-rich yet lightweight. Even runs on MicroPython.
  • Supports both struct-like format string and ctypes-like structure representation (i.e. Structure._field_) as schema.
  • Support schema-less inspection of a given serialized message via the RawWire API.

Getting started

import minipb


# Create the Wire object with schema
hello_world_msg = minipb.Wire([
    ('msg', 'U') # 'U' means UTF-8 string.
])

# Encode a message
encoded_msg = hello_world_msg.encode({
    'msg': 'Hello world!'
})
# encoded_message == b'\n\x0cHello world!'

# Decode a message
decoded_msg = hello_world_msg.decode(encoded_msg)
# decoded_msg == {'msg': 'Hello world!'}


# Alternatively, use the format string
hello_world_msg = minipb.Wire('U')

# Encode a message
encoded_msg = hello_world_msg.encode('Hello world!')
# encoded_message == b'\n\x0cHello world!'

# Decode a message
decoded_msg = hello_world_msg.decode(encoded_msg)
# decoded_msg == ('Hello world!',)

Refer to the Schema Representation for detailed explanation on schema formats accepted by MiniPB.

Installation

CPython, PyPy, etc.

Install via pip

pip install git+https://github.com/dogtopus/minipb

MicroPython

NOTE: Despite being lightweight compared to official Protobuf, the minipb module itself still uses around 15KB of RAM after loaded via import. Therefore it is recommended to use MiniPB on MicroPython instances with minimum of 24KB of memory available to the scripts. Instances with at least 48KB of free memory is recommended for more complex program logic.

On targets with plenty of RAM, such as Pyboards and the Unix build, installation consists of copying minipb.py to the filesystem and installing the logging module from micropython-lib. For targets with restricted RAM there are two options: cross compilation and frozen bytecode. The latter offers the greatest saving. See the official docs for further explanation.

Cross compilation may be achieved as follows. First you need mpy-cross that is compatible with the mpy version you are using.

Compile MiniPB by using

mpy-cross -s minipb.py minipb/minipb.py -o /your/PYBFLASH/minipb.mpy

You also need logging module from micropython-lib. Compile it by using

mpy-cross -s logging.py micropython-lib/logging/logging.py -o /your/PYBFLASH/logging.mpy

Unmount PYBFLASH and reset the board when both files are installed to your MicroPython instance.

On production deployment, it is possible to run mpy-cross with -O set to higher than 0 to save more flash and RAM usage by sacrificing some debuggability. For example -O3 saves about 1KB of flash and library RAM usage while disables assertion and removes source line numbers during traceback.

mpy-cross -s minipb.py -O3 minipb/minipb.py -o /your/PYBFLASH/minipb.mpy
mpy-cross -s logging.py -O3 micropython-lib/logging/logging.py -o /your/PYBFLASH/logging.mpy

Usage

Format string documentation can be found under the project Wiki. The module's pydoc contains some useful information on the API too.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].