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.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.2.tar.gz (169.8 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.2-cp36-cp36m-win_amd64.whl (90.3 kB view details)

Uploaded CPython 3.6mWindows x86-64

python_rapidjson-0.2.2-cp36-cp36m-win32.whl (80.9 kB view details)

Uploaded CPython 3.6mWindows x86

python_rapidjson-0.2.2-cp36-cp36m-manylinux1_x86_64.whl (726.4 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.2.2-cp36-cp36m-manylinux1_i686.whl (694.9 kB view details)

Uploaded CPython 3.6m

python_rapidjson-0.2.2-cp35-cp35m-win_amd64.whl (90.3 kB view details)

Uploaded CPython 3.5mWindows x86-64

python_rapidjson-0.2.2-cp35-cp35m-win32.whl (80.9 kB view details)

Uploaded CPython 3.5mWindows x86

python_rapidjson-0.2.2-cp35-cp35m-manylinux1_x86_64.whl (726.1 kB view details)

Uploaded CPython 3.5m

python_rapidjson-0.2.2-cp34-cp34m-win_amd64.whl (84.5 kB view details)

Uploaded CPython 3.4mWindows x86-64

python_rapidjson-0.2.2-cp34-cp34m-win32.whl (79.9 kB view details)

Uploaded CPython 3.4mWindows x86

python_rapidjson-0.2.2-cp34-cp34m-manylinux1_x86_64.whl (725.7 kB view details)

Uploaded CPython 3.4m

python_rapidjson-0.2.2-cp34-cp34m-manylinux1_i686.whl (697.7 kB view details)

Uploaded CPython 3.4m

File details

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

File metadata

File hashes

Hashes for python-rapidjson-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e7dde8294adbca2134865944788b3da59ffc413dbc71903b2e74fdfc63ee6072
MD5 b8c4f59d1bfd423c95d3e727c82b45af
BLAKE2b-256 461715cc00c13f765bc487d227d99a4fbca5265d1a86c6d3fbe1a991a8f33a06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 bf89233c4bb4626c100cf86c1b9c8299a35ed1b36d882790cc34645bc679f999
MD5 284154529714248908513f016c7ccc9a
BLAKE2b-256 ffe3ca9f1d3ec9459f7aab0c422239ee2963be1f98c219ed3aadfada20de02bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 8b3eb2ce26f38d66fce85e9831d7ad86b0cfd94d4d614d444470b80f2b900e04
MD5 cc00e0a709370053cf3a8a200a9e1006
BLAKE2b-256 cb7ff7c650943dc9d418165b6f71059ff7a3642ba06c9f900231bb801ba67e74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9f93825cb83972055363ae784881a49a2678a44720b94a3f8649e1245f5d1e65
MD5 4838391d99f161e28232a5f6dc7fc71b
BLAKE2b-256 f8dbd392a3b82a5e13e83afd81337e3fa4dab96f26c0ad75a2e5e40770a069c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 75fd838f3eb9f8c98465a5adabce7aaf9cf0c454466b7292347f096b840e2e9d
MD5 ee7877f5b030509f96e0cc0161f4fa9d
BLAKE2b-256 9a4f80832ca48e5c6be8ae26c3357bd860a3663680f82c5c8b38300bb069b7a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 c0c39b6e84bfed1de7a861ddb988b3a522a9586b953711d17a135e6a412790c0
MD5 ab3e86c5dcc0db6171ec8033fd4bbe06
BLAKE2b-256 af9f1fe1e9285b951582ead54fb033bb6b323f903af8fdbd779f3ed918f53813

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 46d0de1183699ec1ba5c79d9d24c3ccdfcf62b26a4813d858a4cda7d8ac8c5bf
MD5 3594d59d536cd10ea49366575adb304f
BLAKE2b-256 45c59b8844da4e8436d1b31e6a4a3fead06fb5c754bc9c1d5abaf4344c504221

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5b98299c8a99e6a8c0cc77c2bc06ccf2ef2fdcffe50cdab08895ecde116c4688
MD5 4a7dc9fc5bb3500f5df60d031934f657
BLAKE2b-256 317b005984ce099420ff030b7d37aa1e44fec985b06704821cd1f97551a02b67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 a93d963c8497b9c09b831a60558bd4b6f6dcfee0566e997ebe88ef6170110dd2
MD5 242f9cd63a796eb16bb9f29f6c372c12
BLAKE2b-256 b3a10f62dedeef26a91fca568599d693a83959595e299b9b8e1bea6b8795b775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 4456c4ec369784799a7fbd36f8f1554e367e9dd7a71867dbbb73e6218daa48a0
MD5 328616646e1e0b5575eef626ef701941
BLAKE2b-256 84092d60110581a7f42d3829a10d0833e15b9638ac5128c59b326212b5866900

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b0c680a53c7febb3017a81c20700692f085892d1e016e808e6f801104414cd2d
MD5 c5725f068c2b33bb52e120ac17c753f7
BLAKE2b-256 7482a1cd1e8c1f78e89ba51b84890fe400f27f70fd2779abc6bad8167402a902

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_rapidjson-0.2.2-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b9e0a57004e3622f720cef9fad68d210c3c244a2dab7decff2099e51aca6a4d9
MD5 b3aa4bcf3896b71beb5cecaa5ff9ff41
BLAKE2b-256 8b1e5d1537affad1a16b63be0357b5841d5cb4f920a2562db467911f0aedec6e

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