Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Independent BSON codec for Python that doesn't depend on MongoDB.
Python
branch: master

This branch is 2 commits ahead of martinkou:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bson
LICENSE
README
setup.py
test.py

README

TO USE:
>> 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'}]}

Currently, bson.dumps() and bson.loads() expects everything to be documents, or
dicts in Python-speak.

Another use case is 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!"})

All the bson networking functions are coded with coroutine based I/O in mind so
it's highly recommended to use it with a coroutine I/O library like gevent or
eventlet. Utilizing bson networking functions without properly patching in
coroutine I/O logic will likely lead to extremely poor performance.

TO INSTALL:
If you want to try out the source package, you do this...
$ ./setup.py build
$ sudo ./setup.py install

Or, you can simply do this instead...
$ sudo easy_install bson
Something went wrong with that request. Please try again.