This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

About

A fast BSON to MongoDB Extended JSON converter for Python.

Installation

python-bsonjs can be installed with pip:

$ python -m pip install python-bsonjs

Examples

>>> import bsonjs
>>> bson_bytes = bsonjs.loads('{"hello": "world"}')
>>> bson_bytes
'\x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00'
>>> bsonjs.dumps(bson_bytes)
'{ "hello" : "world" }'

Using bsonjs with pymongo to insert a RawBSONDocument.

>>> import bsonjs
>>> from pymongo import MongoClient
>>> from bson.raw_bson import RawBSONDocument
>>> client = MongoClient("localhost", 27017, document_class=RawBSONDocument)
>>> db = client.test
>>> bson_bytes = bsonjs.loads('{"_id": 1, "x": 2}')
>>> bson_bytes
'\x15\x00\x00\x00\x10_id\x00\x01\x00\x00\x00\x10x\x00\x02\x00\x00\x00\x00'
>>> result = db.test.insert_one(RawBSONDocument(bson_bytes))
>>> result.inserted_id  # NOTE: inserted_id is None
>>> result.acknowledged
True
>>> raw_doc = db.test.find_one({'x': 2})
>>> raw_doc.raw == bson_bytes
True
>>> bsonjs.dumps(raw_doc.raw)
'{ "_id" : 1, "x" : 2 }'

Speed

bsonjs is roughly 10-15x faster than PyMongo’s json_util at decoding BSON to JSON and encoding JSON to BSON. See benchmark.py:

$ python benchmark.py
Timing: bsonjs.dumps(b)
10000 loops, best of 3: 0.110911846161
Timing: json_util.dumps(bson.BSON(b).decode())
10000 loops, best of 3: 1.46571397781
bsonjs is 13.22x faster than json_util

Timing: bsonjs.loads(j)
10000 loops, best of 3: 0.0628039836884
Timing: bson.BSON().encode(json_util.loads(j))
10000 loops, best of 3: 0.683200120926
bsonjs is 11.72x faster than json_util

Installing From Source

python-bsonjs supports CPython 2.6, 2.7, and 3.3+.

Compiler

You must build python-bsonjs separately for each version of Python. On Windows this means you must use the same C compiler your Python version was built with.

Source

Note that this repository contains a git submodule. You must initialize the submodule by using:

$ git clone --recursive https://github.com/mongodb-labs/python-bsonjs.git

Or, if your version of git does not have clone --recursive:

$ git clone https://github.com/mongodb-labs/python-bsonjs.git
$ cd python-bsonjs
$ git submodule update --init --recursive

Install

Once you have the source properly downloaded, build and install the package:

$ python setup.py install

Test

To run the test suite:

$ python setup.py test
Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
python_bsonjs-0.1.1-cp26-cp26m-macosx_10_11_intel.whl (143.1 kB) Copy SHA256 Checksum SHA256 2.6 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp26-cp26m-manylinux1_i686.whl (234.6 kB) Copy SHA256 Checksum SHA256 cp26 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp26-cp26m-manylinux1_x86_64.whl (255.2 kB) Copy SHA256 Checksum SHA256 cp26 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp26-cp26mu-manylinux1_i686.whl (234.6 kB) Copy SHA256 Checksum SHA256 cp26 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp26-cp26mu-manylinux1_x86_64.whl (255.2 kB) Copy SHA256 Checksum SHA256 cp26 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp26-cp26m-win32.whl (61.0 kB) Copy SHA256 Checksum SHA256 cp26 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp26-cp26m-win_amd64.whl (67.7 kB) Copy SHA256 Checksum SHA256 cp26 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp27-cp27m-macosx_10_11_intel.whl (143.1 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp27-cp27m-manylinux1_i686.whl (234.6 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp27-cp27m-manylinux1_x86_64.whl (255.2 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp27-cp27mu-manylinux1_i686.whl (234.6 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp27-cp27mu-manylinux1_x86_64.whl (255.2 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp27-cp27m-win32.whl (61.0 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp27-cp27m-win_amd64.whl (67.4 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp33-cp33m-manylinux1_i686.whl (234.8 kB) Copy SHA256 Checksum SHA256 cp33 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp33-cp33m-manylinux1_x86_64.whl (256.2 kB) Copy SHA256 Checksum SHA256 cp33 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp33-cp33m-win32.whl (61.3 kB) Copy SHA256 Checksum SHA256 cp33 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp33-cp33m-win_amd64.whl (67.7 kB) Copy SHA256 Checksum SHA256 cp33 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp34-cp34m-macosx_10_6_intel.whl (156.8 kB) Copy SHA256 Checksum SHA256 3.4 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp34-cp34m-manylinux1_i686.whl (234.8 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp34-cp34m-manylinux1_x86_64.whl (256.3 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp34-cp34m-win32.whl (61.3 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp34-cp34m-win_amd64.whl (67.7 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp35-cp35m-macosx_10_6_intel.whl (156.9 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp35-cp35m-manylinux1_i686.whl (235.0 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp35-cp35m-manylinux1_x86_64.whl (256.5 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp35-cp35m-win32.whl (48.5 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Jul 20, 2016
python_bsonjs-0.1.1-cp35-cp35m-win_amd64.whl (54.2 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Jul 20, 2016
python-bsonjs-0.1.1.tar.gz (142.6 kB) Copy SHA256 Checksum SHA256 Source Jul 20, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting