зеркало из https://github.com/github/vitess-gh.git
72a862e6b3 | ||
---|---|---|
.. | ||
bson | ||
LICENSE | ||
PKG-INFO | ||
README | ||
setup.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