Skip to main content

Python wrapper around rapidjson

Project description

RapidJSON is an extremely fast C++ JSON serialization library.

We do not support legacy Python versions, you will need to upgrade to Python 3 to use this library.

Latest version documentation is automatically rendered by Read the Docs.

Build status Documentation status

Getting Started

First install python-rapidjson:

$ pip install python-rapidjson

Basic usage looks like this:

>>> import rapidjson
>>> data = {'foo': 100, 'bar': 'baz'}
>>> rapidjson.dumps(data)
'{"bar":"baz","foo":100}'
>>> rapidjson.loads('{"bar":"baz","foo":100}')
{'bar': 'baz', 'foo': 100}

Development

If you want to install the development version (maybe to contribute fixes or enhancements) you may clone the repository:

$ git clone --recursive https://github.com/python-rapidjson/python-rapidjson.git

A set of makefiles implement most common operations, such as build, check and release; see make help output for a list of available targets.

Performance

python-rapidjson tries to be as performant as possible while staying compatible with the json module.

The following tables show a comparison between this module and other libraries with different data sets. Last row (“overall”) is the total time taken by all the benchmarks.

Each number show the factor between the time taken by each contender and python-rapidjson (in other words, they are normalized against a value of 1.0 for python-rapidjson): the lower the number, the speedier the contender.

In bold the winner.

Serialization

serialize

dumps()[1]

Encoder()[2]

dumps(n)[3]

Encoder(n)[4]

ujson[5]

simplejson[6]

stdlib[7]

yajl[8]

100 arrays dict

1.00

0.99

0.73

0.77

0.97

4.82

2.27

1.37

100 dicts array

1.00

1.02

0.82

0.85

0.90

5.68

2.19

1.36

256 Trues array

1.00

1.04

1.24

1.09

1.31

2.41

2.04

1.12

256 ascii array

1.00

1.01

1.04

1.09

0.49

1.01

0.95

1.08

256 doubles array

1.00

1.02

1.08

1.03

6.76

7.34

6.88

3.89

256 unicode array

1.00

0.89

0.89

0.91

0.56

0.73

0.83

0.47

complex object

1.00

1.01

0.85

0.82

1.04

4.11

2.62

2.16

composite object

1.00

1.02

0.72

0.68

0.88

2.79

1.82

1.71

overall

1.00

0.99

0.73

0.78

0.97

4.81

2.27

1.36

Deserialization

deserialize

loads()[9]

Decoder()[10]

loads(n)[11]

Decoder(n)[12]

ujson

simplejson

stdlib

yajl

100 arrays dict

1.00

1.00

0.90

0.90

0.95

1.60

1.11

1.18

100 dicts array

1.00

1.04

0.86

0.86

0.94

2.00

1.43

1.27

256 Trues array

1.00

1.16

1.10

1.12

1.20

1.95

1.90

1.89

256 ascii array

1.00

1.02

1.02

1.02

1.39

1.14

1.25

1.62

256 doubles array

1.00

0.90

0.16

0.16

0.39

0.86

0.83

0.42

256 unicode array

1.00

1.01

1.01

1.00

1.02

5.14

5.34

2.40

complex object

1.00

1.01

0.73

0.73

0.88

1.60

1.14

1.20

composite object

1.00

1.02

0.81

0.81

0.85

1.97

1.42

1.26

overall

1.00

1.00

0.90

0.90

0.95

1.61

1.12

1.18

DIY

To run these tests yourself, clone the repo and run:

$ make benchmarks

or

$ make benchmarks-other

The former will focus only on RapidJSON and is particularly handy coupled with the compare past runs functionality of pytest-benchmark:

$ make benchmarks PYTEST_OPTIONS=--benchmark-autosave
# hack, hack, hack!
$ make benchmarks PYTEST_OPTIONS=--benchmark-compare=0001

----------------------- benchmark 'deserialize': 18 tests ------------------------
Name (time in us)                                                            Min…
----------------------------------------------------------------------------------
test_loads[rapidjson-256 Trues array] (NOW)                         5.2320 (1.0)
test_loads[rapidjson-256 Trues array] (0001)                        5.4180 (1.04)

To reproduce the tables above run make benchmarks-tables

Incompatibility

Here are things in the standard json library supports that we have decided not to support:

separators argument

This is mostly used for pretty printing and not supported by RapidJSON so it isn’t a high priority. We do support indent kwarg that would get you nice looking JSON anyways.

Coercing keys when dumping

json will turn True into 'True' if you dump it out but when you load it back in it’ll still be a string. We want the dump and load to return the exact same objects so we have decided not to do this coercion.

Changes

0.2.4 (2017-09-17)

  • Fix compatibility with MacOS/clang

0.2.3 (2017-08-24)

  • Limit the precision of DM_UNIX_TIME timestamps to six decimal digits

0.2.2 (2017-08-24)

  • Nothing new, attempt to fix production of Python 3.6 binary wheels

0.2.1 (2017-08-24)

  • Nothing new, attempt to fix production of Python 3.6 binary wheels

0.2.0 (2017-08-24)

  • New parse_mode option, implementing relaxed JSON syntax (issue #73)

  • New Encoder and Decoder, implementing a class-based interface

  • New Validator, exposing the underlying JSON schema validation (issue #71)

0.1.0 (2017-08-16)

  • Remove beta status

0.1.0b4 (2017-08-14)

  • Make execution of the test suite on Appveyor actually happen

0.1.0b3 (2017-08-12)

  • Exclude CI configurations from the source distribution

0.1.0b2 (2017-08-12)

  • Fix Powershell wheel upload script in appveyor configuration

0.1.0b1 (2017-08-12)

  • Compilable with somewhat old g++ (issue #69)

  • Backward incompatibilities:

    • all DATETIME_MODE_XXX constants have been shortened to DM_XXX DATETIME_MODE_ISO8601_UTC has been renamed to DM_SHIFT_TO_UTC

    • all UUID_MODE_XXX constants have been shortened to UM_XXX

  • New option DM_UNIX_TIME to serialize date, datetime and time values as UNIX timestamps targeting issue #61

  • New option DM_NAIVE_IS_UTC to treat naïve datetime and time values as if they were in the UTC timezone (also for issue #61)

  • New keyword argument number_mode to use underlying C library numbers

  • Binary wheels for GNU/Linux and Windows on PyPI (one would hope: this is the reason for the beta1 release)

0.0.11 (2017-03-05)

  • Fix a couple of refcount handling glitches, hopefully targeting issue #48.

0.0.10 (2017-03-02)

  • Fix source distribution to contain all required stuff (PR #64)

0.0.9 (2017-03-02)

0.0.8 (2016-12-09)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-rapidjson-0.2.4.tar.gz (170.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_rapidjson-0.2.4-cp36-cp36m-win_amd64.whl (90.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

python_rapidjson-0.2.4-cp36-cp36m-win32.whl (81.2 kB view details)

Uploaded CPython 3.6mWindows x86

python_rapidjson-0.2.4-cp36-cp36m-manylinux1_x86_64.whl (731.0 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.2.4-cp36-cp36m-manylinux1_i686.whl (696.4 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.2.4-cp35-cp35m-win_amd64.whl (90.6 kB view details)

Uploaded CPython 3.5mWindows x86-64

python_rapidjson-0.2.4-cp35-cp35m-win32.whl (81.2 kB view details)

Uploaded CPython 3.5mWindows x86

python_rapidjson-0.2.4-cp35-cp35m-manylinux1_x86_64.whl (730.5 kB view details)

Uploaded CPython 3.5m

python_rapidjson-0.2.4-cp35-cp35m-manylinux1_i686.whl (696.0 kB view details)

Uploaded CPython 3.5m

python_rapidjson-0.2.4-cp34-cp34m-win_amd64.whl (84.9 kB view details)

Uploaded CPython 3.4mWindows x86-64

python_rapidjson-0.2.4-cp34-cp34m-win32.whl (80.8 kB view details)

Uploaded CPython 3.4mWindows x86

python_rapidjson-0.2.4-cp34-cp34m-manylinux1_x86_64.whl (730.1 kB view details)

Uploaded CPython 3.4m

python_rapidjson-0.2.4-cp34-cp34m-manylinux1_i686.whl (695.8 kB view details)

Uploaded CPython 3.4m

File details

Details for the file python-rapidjson-0.2.4.tar.gz.

File metadata

File hashes

Hashes for python-rapidjson-0.2.4.tar.gz
Algorithm Hash digest
SHA256 60d7844b63a015a00182e8b9bf0ee7e64995699bcbbad3fb79b2e5fb999ccd3c
MD5 5b438957108faddee3db1b04d4d2daa7
BLAKE2b-256 e1dfa13733b141c19783069868644ef99058a7cb49ab71a626bfeeb82885f800

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 729aace8d3a63905873be08971247a1605ec9685ffcc5cf9f7e61b1699d89563
MD5 ee3dc2ad638d7f89136bff1c9cd4cd32
BLAKE2b-256 63155c01be33bbc05d47df7805bc8eba4c2c575003e542982cb80797fb18fe48

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 414cd9f49906c027ecaa359186ba41ad6948e41a2f6c3d0da465ac3c11b37ce9
MD5 7340c5fcb114f161bffa2d08463377f8
BLAKE2b-256 dd6d97bc86e9dbe7ef7355fb92274b93a98e79987d336cd7133cc8a0daca009f

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 feef6ebb57f4f0f53969de19d35290a754aea7cf49b9d848029d590059ccf768
MD5 52b2a48615e8960ada96427ac2920080
BLAKE2b-256 e7bfbabbc12b23a908c05a563eaa25314268fd3b0405a10feb04312a2e825157

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 901262e0afd772ddd31e1ed4b75b95bc0806afcf4118545446cc115ccf1edcee
MD5 0783ec43158215591de839a02a668438
BLAKE2b-256 e3d6ff9234655a70362d670a1eda9fdff45befd356f2f210369c210233f1a368

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 5d71b3722ac7e6654a7268cf4bb1105a206a95416cab83a4f6c82082ea067876
MD5 cf018842ec4c7a43e731f5d4c756ee7c
BLAKE2b-256 212068d721dde586933a364fd86d5059ea08881739346fe816f98c0f20e7d002

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 2dccfbb9a3fca81defcda820dfaeddb2656b75df422a112a0886035d3d062a76
MD5 7c7b4ec2ddf1351e18e26587e53850f9
BLAKE2b-256 bbd75c67f693f957731a9cb99ae347019ce7bfb9b1285298940afe05269aea8f

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e941125ce56332be9bb66e6d629e3d2858821bca8b6ad2005ec003bde25a52a7
MD5 69f0b5f49ef15aa093cec6c1dbd37f08
BLAKE2b-256 d3a7b10d912bdcccf1a12efccd034402bb80df3b994249c133ea7c9c515d5b66

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b878e2411f9323edb706cfe89428daf041219573cc175491e51e4c73d5d00111
MD5 81cd5d0d24e6c204684b7a72c3dada12
BLAKE2b-256 843c3fbf6e36b41503ca6c1c43d49cc700d40e0cd67d294197b4a72339c2a650

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp34-cp34m-win_amd64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 dc85dd9711e05e49c55ae68ad2804b8ddfba9756a6fa9103c9c4a509238035bf
MD5 0722bd726800367353d7d7dc37d60f23
BLAKE2b-256 b7ff3af78b99c16ff383ed12d4fc2ba8b9811cf01eb494b3f24d65ef7fb46d2b

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp34-cp34m-win32.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 fbc2f7198c157af14d9eda9a988394a27c56c0418db503bf7c6b28f93bdb30a3
MD5 307eb4c2f39043a48341d2d36d6db3df
BLAKE2b-256 f6d0e4e7ff9f441ced54404d26a51a25300397b728c7a7cd6f389e25e30fd6b0

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 93f58ecf8797bc601c58fcf9555815f582e9f3e7ecfd33b475fadcf1ea62d569
MD5 f6ce7a7eddd47e74e74931ba0f99823c
BLAKE2b-256 d0de914abf4a746640a04a8b295dc9f3c16ac6c8e40746b39a860c424a738126

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.2.4-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.2.4-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4c09231209b2100ab6e9ae59cc10cc8164967e1522f75f1ef7a0d10d15772dfa
MD5 398b2147fac7b6e1401173c5277efc44
BLAKE2b-256 eb4f1d60d8f21dfa04fcf1338d11da4ddd720e22e1219534cf4f35804b2480e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page