fast_bson

BSON codec for Python


Keywords
BSON, codec
License
BSD-3-Clause
Install
pip install fast_bson==0.0.1

Documentation

bson

Independent BSON codec for Python that doesn't depend on MongoDB.

This package is basically https://github.com/py-bson/bson but with some terrible hacks to make it faster.

Installation

~ $ python setup.py install

or can use pip

~ $ pip install fast_bson

Quick start

>>> import bson
>>> a = bson.dumps({"A":[1,2,3,4,5,"6", u"7", {"C":u"DS"}]})
>>> b = bson.loads(a)
>>> b
{'A': [1, 2, 3, 4, 5, '6', u'7', {'C': u'DS'}]}

Sending and receiving BSON objects to and from network sockets.

>>> from gevent import monkey, socket
>>> monkey.patch_all()
>>>
>>> import bson
>>> bson.patch_socket()
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(("127.0.0.1", 12345))
>>> s.sendobj({u"message" : "hello!"})