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.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.1.0b4.tar.gz (162.0 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.1.0b4-cp36-cp36m-win_amd64.whl (48.9 kB view details)

Uploaded CPython 3.6mWindows x86-64

python_rapidjson-0.1.0b4-cp36-cp36m-win32.whl (46.1 kB view details)

Uploaded CPython 3.6mWindows x86

python_rapidjson-0.1.0b4-cp36-cp36m-manylinux1_x86_64.whl (319.1 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.1.0b4-cp36-cp36m-manylinux1_i686.whl (310.0 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.1.0b4-cp35-cp35m-win_amd64.whl (48.9 kB view details)

Uploaded CPython 3.5mWindows x86-64

python_rapidjson-0.1.0b4-cp35-cp35m-win32.whl (46.1 kB view details)

Uploaded CPython 3.5mWindows x86

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

Uploaded CPython 3.5m

python_rapidjson-0.1.0b4-cp35-cp35m-manylinux1_i686.whl (309.8 kB view details)

Uploaded CPython 3.5m

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

Uploaded CPython 3.4mWindows x86-64

python_rapidjson-0.1.0b4-cp34-cp34m-win32.whl (44.7 kB view details)

Uploaded CPython 3.4mWindows x86

python_rapidjson-0.1.0b4-cp34-cp34m-manylinux1_x86_64.whl (318.8 kB view details)

Uploaded CPython 3.4m

python_rapidjson-0.1.0b4-cp34-cp34m-manylinux1_i686.whl (309.6 kB view details)

Uploaded CPython 3.4m

File details

Details for the file python-rapidjson-0.1.0b4.tar.gz.

File metadata

File hashes

Hashes for python-rapidjson-0.1.0b4.tar.gz
Algorithm Hash digest
SHA256 498dbfbeb9787f8797cd4f02425e768264bc7deb7f3a56a8c710c767e049f31a
MD5 9731d107e5f20a663144f6cad3de23fd
BLAKE2b-256 ff8e60bd9ede0721e35c56436d5a01fe675397c52d4423f9d0ee92bab79d7044

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d350d1a7ec6b4983fe0f0d753cced8bc3493d5954e19112f986fc7a0612039de
MD5 5057a9dd789635290746332d6ad032f3
BLAKE2b-256 2107a76b4bc9082b19fdb94fadadcdf2a0b063079da6387c5ee22774df52b974

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 e5bc16e349a13cf577c86a838f9f602f6602ae25f5b77f9552443313299229ae
MD5 b0abf1a24d55c83a0c2180c2f9d07bce
BLAKE2b-256 54be3c4b54953bd901696515e6b7fca1b5d57e12ff77062fc39c7eb55b7f4be6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 53829c82688010572b1f90bd8c2135b86b821e40a2c341e3627b22867a543b09
MD5 865c73908645b28c555e46bb35c8b497
BLAKE2b-256 467ed27b618f627954fd9e8454c73180e5c3b634ccf38303fd4cf8f229b8e794

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b9eb669efded1202f0f8677916a795cc6170bf2f3cb18d19dfd8c626418a2c7d
MD5 04158b12ceddab860ff2daed955504b2
BLAKE2b-256 206c5dd4a9412abf3f6e884ea7a2347b9866dd79bfec524699106348ef7addc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 1a02a197e46e3b4f87c99b19882287b74998d99bd20be5c8acc0574394afc690
MD5 765b380bfd09ec0aa6fa09fde594f137
BLAKE2b-256 04960d787f74486f3f0ec9cbdab27ee350345e8b5a3e68e65b24a36caf16edf2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 01fd443164dc58e63d1cf1ba65c700cd3bac9e94cad26c808635c776a1c0b8a5
MD5 1ad24c789ae70f8da59d090fdbea06aa
BLAKE2b-256 7e58cbf5cfece2094624579f2e9130668f8d4bdfc786f3acb9ed66da52f687bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1e2840f7cfd40f65239d3eb8cc6824ac214efe503d362420a9b974af5ab91fc3
MD5 0a4736c66415154982427754d4297bbe
BLAKE2b-256 f953be2ffc6b79bf18be579361d5fbfcb82ba31930cf39ae439b1714a96b88f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1dc21d42691543e9bd74bbd5918511697046440a4e54a5bd251d29b9763daa7c
MD5 2b440e02d17609a2aa7657db089afd60
BLAKE2b-256 f703f060c28b9adef73b0a6dc7fbc8552f86997ec95b29894bf9eeb50c7c11eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 2de4109147e69f635f84072149c9430d9f9c330eebcdbc5cab9e6913c2b7405a
MD5 89f4e8965792866edf149eaffaa0df6f
BLAKE2b-256 bdbef9fd1bde81ac7757cd0d17999b5187555df6535b78f59161fef4f7aa1424

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 5c6ae79f5646e2e8ced95b24c866860ba06fbdf1ef5549ad7973042007832be7
MD5 bca82dc9e43c3a66f3c3d60d40a89a29
BLAKE2b-256 2694b8d9318f91fc5b4b4a5a1e4743ef1f25d8a4bd9326806c899c34ca59b7ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 945a3e74e576dbf0dac31c0ee7fa6c12b564ef1ea54153f5302b9db5869093fb
MD5 2ab1b0f21c5e0d4fda9daef6d2db3f18
BLAKE2b-256 656b1c577ec7a13b1033cef8fab5cfd8bc3c2a422393207bdb2306bc3a5397bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.1.0b4-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 40e2c0b0e3c0ce5034a22f75c882db81b9def94ca4c1e7c8c4b5d33071b920ea
MD5 c7a0b717b55d0a189bd0ea7683bc496b
BLAKE2b-256 5a50f339d86f5d1a095177cff0d548a57340e51a9c5796acb997cb6654eb4e3f

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