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

RapidJSON tries to be compatible with the standard library json module so it should be a drop in replacement. 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}

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

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

native [1]

ujson [2]

simplejson [3]

stdlib [4]

yajl [5]

100 arrays dict

0.67

1.31

6.28

2.88

1.74

100 dicts array

0.79

1.19

7.16

2.92

1.69

256 Trues array

1.19

1.41

3.02

2.19

1.20

256 ascii array

1.02

0.92

1.90

1.77

2.05

256 doubles array

1.06

7.55

8.30

7.65

4.39

256 unicode array

0.87

0.72

0.82

0.88

0.53

complex object

0.82

1.41

5.17

3.39

2.87

composite object

0.68

0.93

3.01

1.92

1.85

overall

0.67

1.30

6.27

2.88

1.74

Deserialization

deserialize

native

ujson

simplejson

stdlib

yajl

100 arrays dict

0.90

0.97

1.48

1.25

1.20

100 dicts array

0.88

0.96

1.99

1.58

1.34

256 Trues array

1.22

1.31

2.08

1.93

2.08

256 ascii array

1.05

1.37

1.14

1.25

1.56

256 doubles array

0.16

0.33

0.72

0.70

0.47

256 unicode array

0.89

0.79

4.12

4.50

1.90

complex object

0.72

0.88

1.36

1.28

1.24

composite object

0.83

0.85

1.94

1.43

1.26

overall

0.90

0.97

1.49

1.25

1.20

DIY

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

$ tox -e py36 -- -m benchmark --compare-other-engines

Without the option --compare-other-engines it will focus only on RapidJSON. This is particularly handy coupled with the compare past runs functionality of pytest-benchmark:

$ tox -e py36 -- -m benchmark --benchmark-autosave
# hack, hack, hack!
$ tox -e py36 -- -m benchmark --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, use the option --benchmark-json so that the the results are written in the specified filename the run the benchmark-tables.py script giving that filename as the only argument:

$ tox -e py36 -- -m benchmark --compare-other-engines --benchmark-json=comparison.json
$ python3 benchmark-tables.py comparison.json

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 coercing.

Changes

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

python_rapidjson-0.1.0b3-cp36-cp36m-win_amd64.whl (48.8 kB view details)

Uploaded CPython 3.6mWindows x86-64

python_rapidjson-0.1.0b3-cp36-cp36m-win32.whl (46.0 kB view details)

Uploaded CPython 3.6mWindows x86

python_rapidjson-0.1.0b3-cp36-cp36m-manylinux1_x86_64.whl (319.0 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.1.0b3-cp36-cp36m-manylinux1_i686.whl (309.9 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.1.0b3-cp35-cp35m-win_amd64.whl (48.8 kB view details)

Uploaded CPython 3.5mWindows x86-64

python_rapidjson-0.1.0b3-cp35-cp35m-win32.whl (46.0 kB view details)

Uploaded CPython 3.5mWindows x86

python_rapidjson-0.1.0b3-cp35-cp35m-manylinux1_x86_64.whl (318.9 kB view details)

Uploaded CPython 3.5m

python_rapidjson-0.1.0b3-cp35-cp35m-manylinux1_i686.whl (309.7 kB view details)

Uploaded CPython 3.5m

python_rapidjson-0.1.0b3-cp34-cp34m-win_amd64.whl (44.7 kB view details)

Uploaded CPython 3.4mWindows x86-64

python_rapidjson-0.1.0b3-cp34-cp34m-win32.whl (44.6 kB view details)

Uploaded CPython 3.4mWindows x86

python_rapidjson-0.1.0b3-cp34-cp34m-manylinux1_x86_64.whl (318.7 kB view details)

Uploaded CPython 3.4m

python_rapidjson-0.1.0b3-cp34-cp34m-manylinux1_i686.whl (309.5 kB view details)

Uploaded CPython 3.4m

File details

Details for the file python_rapidjson-0.1.0b3-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 6812e965f85d7e190d0a91e3b002b7edbae3434dad2f9b7c13d8b043d900aca7
MD5 a4f67e9e5c018938ff2651a6e61175e3
BLAKE2b-256 edf4aab820e0e4b0f265151792a02f56c074c4a9ecbd77d5c03f5a7404633cb6

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 a6ac08ea51638168fb6669fe89146469dff0fb214737e2a5d041e03c240c2bb9
MD5 c11460a0c6332366fa12198ffabee39f
BLAKE2b-256 82a0eff83cc16ee8b577f539b0ebc57e8d676ef3c075bebfeab3325508336ec3

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e6dfcfeec83a29b7b6ad43b315999036a00e15a3fb43437f9b04915d49f3c503
MD5 db8c2d78c1272e443d0f09e71126021c
BLAKE2b-256 fbce1144c142e6bb307ba03b2b51d3440f1c2cf5f77976b281269cad56cca4e1

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 cf3199b600ff13410a3f50e72ac44cb03ae9c1a20b42440d46fd09dda3777932
MD5 9a5402186505117e68105cd433028987
BLAKE2b-256 57673d3c08a541e6cdea56385e2b23ae147f3c971d03e5acc4c1caa80bf38489

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 a1c11ede2da467ffab474dd8789fe07013dea71df73c916fbef38741d3ec3d83
MD5 a11286a98ae35fda6110c45cc0a8f601
BLAKE2b-256 d54f90e0481afc2643a1f42a64c0f86e45ae157400160eeb441ea38cd6663dca

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 e24f880e74781566f1bc9bf32ae5a05ca8a17c4ab98c63c2d49f1023423437b0
MD5 fd64a0820bbe04cc85b4f59b9796e53e
BLAKE2b-256 32346229ec2ae2fb49e2b4ea68ba2123f32ad19de516705f370c0577ead21d22

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 07a52fe72dc1c979a4deccd1203e335c0f626e6cf23966b252943da8e14d7be5
MD5 5ab0c71443ea4faa88eb22504b3d6b52
BLAKE2b-256 df697656a6fc1717c48d55eb38bbd86374ff2b1255f71bbe458040c119022e44

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 97597f7b18881d89fd61a58f1f8f26e77e3676aad20dca2a166fff17867ce84e
MD5 e00ad50ef9284dab01b4a1a8b4626a22
BLAKE2b-256 4c222ed545705de321d262ed8e04abd3780c537450cc418e8b89a69d40511c8a

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp34-cp34m-win_amd64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 67762491e3b4a2ae77e6294c16ea9b5c9ba7098bca8e9be55c5ce91c262cf745
MD5 088b32889c072524819d54091da7dbec
BLAKE2b-256 b6ba10e96b9b83febe1ee069c5d9aa257e5aa0e85641c704dbe54d1281c52d0f

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp34-cp34m-win32.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 229c1f96f79e4984b83dc9517046e4806a8c7b5594b9a96866fbfc9a908acdc9
MD5 6bec8d11805a9612a4a490b591eae49c
BLAKE2b-256 66795d28fd7fe80401bff94fd01ce21579650fabcad57606998b1385cb0143eb

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b52a1a9e4b6c8066fe14876bf14ea62ec202909a3319cc6effdf79068e22b850
MD5 7dae999266831319d7db84c86d585c54
BLAKE2b-256 e55a7bc30176ace466bc546d9e1cbf51e7ddb9149756200090bc02149cb80a82

See more details on using hashes here.

File details

Details for the file python_rapidjson-0.1.0b3-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b3-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6c99e4d11a95d7ee525a4490704db1fcbcf3207564e235e8b07ed45f11c42b45
MD5 24476435e756ce56ec2cef0ffbe5a7e8
BLAKE2b-256 6d789cbb7ef13e7a3920f528778e6c7160777cdec051b2fc17e3c9422dd181f4

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