Coder Social home page Coder Social logo

mugenzebra / lwpb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acg/lwpb

0.0 1.0 0.0 2.25 MB

Lightweight Protocol Buffers for C and Python

Home Page: http://code.google.com/p/lwpb/

License: Apache License 2.0

Makefile 0.61% Shell 0.01% C 69.42% Python 6.01% C++ 13.86% Protocol Buffer 2.62% PureBasic 0.26% SourcePawn 7.22%

lwpb's Introduction

lwpb

The "Lightweight Protocol Buffer Library" provides fast encoding and decoding of Google Protocol Buffers in C and Python.

Some distinctive things about lwpb:

  • lwpb does not require a codegen step.

  • lwpb does not force OO on the programmer. Encoding and decoding works with dicts in Python, and plain old structures in C.

  • lwpb is fast and small. The C library is 31kb stripped. The Python module is mostly written in C and performs well in benchmarks.

  • lwpb does not depend on Google's C++ API or anything outside the Python standard libraries.

  • lwpb supports most features of the protocol buffer serialization format -- probably, all the ones you care about. :)

Python library

Quick Python synopsis:

from lwpb.codec import MessageCodec

codec = MessageCodec( pb2file='person.pb2', typename='example.Person' )
serialized = codec.encode( { 'name': 'John Doe', 'id': 1234  } )
deserialized = codec.decode( serialized )

print deserialized

This expects a compiled .proto file you can generate with:

protoc person.proto -o person.pb2

To build the Python module, first compile the C library (see below), then:

cd python
./build_inplace
python setup.py test
python setup.py build
python setup.py install

For Debian and Ubuntu users:

cd python
debian/rules binary
dpkg -i ../*.deb

C library

The C library was originally released by Simon Kallweit. More documentation on the C API can be found here: http://code.google.com/p/lwpb/

To compile:

make

To test it:

make check

Performance

From a recent benchmark which included the lwpb Python module (lower times are better):

JSON
3.56521892548

SimpleJSON 
0.727998971939

Protocol Buffer (fast)
0.38397192955

Protocol Buffer (standard)
4.86640501022

Protocol Buffer (lwpb)
0.323328971863

cPickle
0.811990976334

Completeness

Supported types:

  • INT32
  • UINT32
  • INT64
  • UINT64
  • FIXED32
  • FIXED64
  • SFIXED32
  • SFIXED64
  • DOUBLE
  • FLOAT
  • BOOL
  • STRING
  • MESSAGE
  • BYTES
  • ENUM

That is to say, everything but GROUP, which Google has deprecated.

Supported options:

  • packed repeated fields

Supported by the C library, but not by the Python library:

  • services
  • RPC

Not supported:

  • extensions

lwpb's People

Contributors

acg avatar nickva avatar

Watchers

 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.