vitess-gh/third_party/py/bson-0.3.2
Sugu Sougoumarane 72a862e6b3 initial source code check-in. 2012-02-24 23:30:03 -08:00
..
bson initial source code check-in. 2012-02-24 23:30:03 -08:00
LICENSE initial source code check-in. 2012-02-24 23:30:03 -08:00
PKG-INFO initial source code check-in. 2012-02-24 23:30:03 -08:00
README initial source code check-in. 2012-02-24 23:30:03 -08:00
setup.py initial source code check-in. 2012-02-24 23:30:03 -08:00

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