Python wrapper around rapidjson
Project description
RapidJSON is an extremely fast C++ JSON parser and serialization library: this module wraps it into a Python 3 extension, exposing its serialization/deserialization (to/from either bytes, str or file-like instances) and JSON Schema validation capabilities.
Latest version documentation is automatically rendered by Read the Docs.
Getting Started
First install python-rapidjson:
$ pip install python-rapidjson
or, if you prefer Conda:
$ conda install -c conda-forge 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}
>>>
>>> class Stream:
... def write(self, data):
... print("Chunk:", data)
...
>>> rapidjson.dump(data, Stream(), chunk_size=5)
Chunk: b'{"foo'
Chunk: b'":100'
Chunk: b',"bar'
Chunk: b'":"ba'
Chunk: b'z"}'
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.
See the this section in the documentation for a comparison with other JSON libraries.
Incompatibility
Although we tried to implement an API similar to the standard library json, being a strict drop-in replacement in not our goal and we have decided to depart from there in some aspects. See this section in the documentation for further details.
Changes
1.0 (2020-12-13)
Require Python 3.6 or greater
New serialization options, iterable_mode and mapping_mode, to give some control on how generic iterables and mappings get encoded (fix issue #149 and issue #150)
Internal refactorings, folding “skipkeys” and “sort_keys” arguments into the mapping_mode options, respectively as MM_SKIP_NON_STRING_KEYS and MM_SORT_KEYS: “old” arguments kept for backward compatibility
Bump major version to 1, tag as “production/stable” and switch to a simpler X.Y versioning schema
0.9.4 (2020-11-16)
Fix memory leak loading an invalid JSON (issue #148)
0.9.3 (2020-10-24)
Fix access to Encoder instance attributes (issue #147)
0.9.2 (2020-10-24)
Use current master version of rapidjson
Enable GH Actions-based test workflow, thanks to Martin Thoma (PR #143)
Produce Python 3.9 wheels, disable testing under Python < 3.6
Make the character used for indentation in pretty mode a parameter (issue #135)
Handle wider precision range in timestamps fractional seconds (PR 133), thanks to Karl Seguin
Add comparison benchmarks against orjson and hyperjson (issue #130 and PR #131, thanks to Sebastian Pipping)
0.9.1 (2019-11-13)
Fix memory leak in case of failed validation (issue #126)
0.9.0 (2019-11-13)
Produce Python 3.8 wheels
Compatibility fix for Python 3.8 (issue #125)
New dump option write_mode, supporting RapidJSON’s kFormatSingleLineArray option (issue #123), thanks to Nguyễn Hồng Quân for the initial implementation (PR #124)
0.8.0 (2019-08-09)
New serialization option bytes_mode to control how bytes instances get encoded (issue #122)
0.7.2 (2019-06-09)
Hopefully fix the memory leak when loading from a stream (issue #117)
0.7.1 (2019-05-11)
Raise a more specific exception on loading errors, JSONDecodeError, instead of generic ValueError (issue #118)
Fix optimization path when using OrderedDicts (issue #119)
Fix serialization of IntEnums (issue #121)
I spent quite a lot of time investigating on the memory leak when loading from a stream (issue #117): as I was not able to fully replicate the problem, I cannot be sure I solved the problem… sorry!
0.7.0 (2019-02-11)
Raise correct exception in code samples (PR #109), thanks to Thomas Dähling
Fix compilation with system-wide install of rapidjson (issue #110)
Use current master version of rapidjson, that includes a fix for its issue #1368 and issue #1336, and cures several compilation warnings as well (issue #112 and issue #107)
Fix memory leak when using object_hook (issue #115)
0.6.3 (2018-07-11)
No visible changes, but now PyPI carries binary wheels for Python 3.7.
0.6.2 (2018-06-08)
Use a more specific ValidationError, to differentiate from invalid JSON
0.6.1 (2018-06-06)
Nothing new, attempt to build Python 3.6 binary wheels on Travis CI
0.6.0 (2018-06-06)
Add a new comparison table involving ensure_ascii (issue #98)
Use Python’s repr() to emit float values instead of rapidjson’s dtoa() (issue #101)
Use a newer (although unreleased) version of rapidjson to fix an issue with JSONSchema validation (PR #103), thanks to Anthony Miyaguchi
0.5.2 (2018-03-31)
Tiny tweak to restore macOS build on Travis CI
0.5.1 (2018-03-31)
Minor tweaks to CI and PyPI deploy configuration
0.5.0 (2018-03-31)
0.4.3 (2018-01-14)
Deserialize from bytes and bytearray instances, ensuring they contain valid UTF-8 data
Speed up parsing of floating point numbers, avoiding intermediary conversion to a Python string (PR #94)
0.4.2 (2018-01-09)
Fix precision handling of DM_UNIX_TIME timestamps
0.4.1 (2018-01-08)
Fix memory leaks in Decoder() and Encoder() classes, related to bad handling of PyObject_GetAttr() result value
Fix compatibility with Python 3.7a
0.4.0 (2018-01-05)
0.3.2 (2017-12-21)
Reduce compiler warnings (issue #87)
0.3.1 (2017-12-20)
Fix Travis CI recipe to accomodate MacOS
0.3.0 (2017-12-20)
Fix compilation on MacOS (issue #78)
Handle generic iterables (PR #89)
Backward incompatibility: the dumps() function and the Encoder() constructor used to accept a max_recursion_depth argument, to control the maximum allowed nesting of Python structures; since the underlying function is now effectively recursive, it has been replaced by the generic sys.setrecursionlimit() mechanism
0.2.7 (2017-12-08)
Restore compatibility with Python < 3.6
0.2.6 (2017-12-08)
Fix memory leaks when using object_hook/start_object/end_object
0.2.5 (2017-09-30)
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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for python_rapidjson-1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00b7679ed075e4353beb2a728743d24096942faa008065ea4fd242dc91dc496b |
|
MD5 | c07e8c47ee64b5913b66cc7920daff1b |
|
BLAKE2b-256 | cdb5c553fe40f1a4d1c45aacdf302792526ec1525641b07cf261be9dc36661d9 |
Hashes for python_rapidjson-1.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c446153975c5d9467fcdb8ea8545a7d2a991e0693fa84e38865eec821cc66584 |
|
MD5 | cde86aa2f48d309c60e1429bc355ceec |
|
BLAKE2b-256 | a8a7b202c7444b3567a22989771954d8b5a96e57feeacd45d9b4bbe0ad3dde8e |
Hashes for python_rapidjson-1.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df72847d0c44969c9c49e3bd9df77a7580f43875427d865edfafd344901c22a0 |
|
MD5 | 5f9b2dcb43c1e3abcf97af16c908fc0f |
|
BLAKE2b-256 | 2f44500351e8b9d11257ceca21ea642ac10f1f5a30c8075c09f962b4515d14b2 |
Hashes for python_rapidjson-1.0-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49dae9df02fdabdbcbd6651a98a569b6e6c4ffdc2c7d2af7be805ff40005be03 |
|
MD5 | 8283a1d2bb907ae287a41ea84134ab02 |
|
BLAKE2b-256 | 0523e4b21fd4782fb1d97feea4ec9eb1f7c8be14caff595acfdc600158fc2083 |
Hashes for python_rapidjson-1.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 987eba5e8b647c4f7e4249bdec870ab57d2b70b58d9e23b530c1047bd17c58ba |
|
MD5 | e9553052738e590841405c7b9e469da8 |
|
BLAKE2b-256 | 64b6e6fda1635b3a54f44cbc66a1fc0032cd2fa6994bb5bd6f750c3f11c31262 |
Hashes for python_rapidjson-1.0-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb249674ddf238ea12ff84efc5b3ec868174dd54419ec2ad51601a834716757d |
|
MD5 | b2e844f5ae7f411a0ce781630d0ffdd9 |
|
BLAKE2b-256 | ab95b1e41c8f09043e3ad87d2c90db9dcd6f308550b007700617a5404753bdbb |
Hashes for python_rapidjson-1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4446c481bf469ae4c22d97c358b95091eb528612dac0cf15e50e112a04b22ded |
|
MD5 | b9dbd149a7d8cfbcf54572296d2cfcf6 |
|
BLAKE2b-256 | 8ba5eed732e545f0389fcb26069a0cfeb0e0edd932b03f1b4efe4185f7a62c01 |
Hashes for python_rapidjson-1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbc05e61d7e0754741382c747b3fd8af8267a5dac1d0e6bf6c3b611584373ac1 |
|
MD5 | 0cc0379914b1fe52836e8a4ae8559df5 |
|
BLAKE2b-256 | 9705d5aa218b55b9ede0e123b5573a6661dedc8db99e61797dce8bc07e0527a3 |
Hashes for python_rapidjson-1.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb158c3e53df83669e6dfd34fcc17edc2fdda9d466165d9798af06a7b5b878f3 |
|
MD5 | 528ea4eb874f9e1b427caa11495a6451 |
|
BLAKE2b-256 | 5ac136b0479320a2832f7bd2d89b2041bb1d766c0edb5c9e01683d2909a70465 |
Hashes for python_rapidjson-1.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cf70741471e58983d29cfcb3b37a30bfe947519973fc206958d30d5a3504ae2 |
|
MD5 | a63c9351190fbf15d5d43d518ebc820f |
|
BLAKE2b-256 | ac7b873230a6ca30858bffdf33e9565cb0ce46fb8572633d9dcc004e6e3f76e1 |
Hashes for python_rapidjson-1.0-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88242ac09c42780c88ad348f35be83b688e594961ef1d8d75943cbca8ff23492 |
|
MD5 | 0358b932aa578641729958ac274d1d87 |
|
BLAKE2b-256 | c5280bbc6d808b3acae6592ac52011f3a4b009dc79e033d2ab26bd068065592e |
Hashes for python_rapidjson-1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e385ed2838511acbde8a2ba362fe6aedf5a1cb1365ecc30f19f99da20280dfb |
|
MD5 | 64dfb098205c803833aca76540f8f4c8 |
|
BLAKE2b-256 | dcf731d06332354e4f83136dfe1ae576371f34264fb9232b2ee5d9d7144e506d |
Hashes for python_rapidjson-1.0-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48da6c391e636a93989eb4994f81aad2915375763909e222896ee8b80600a812 |
|
MD5 | 314a6fa9b33f04ec25cf5af5e2e4e39a |
|
BLAKE2b-256 | d1f195c460e8c290c06fe3cb5d191479cc74ae66b2ef5db93f5c5d6d938319a0 |
Hashes for python_rapidjson-1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72a22106bd49212d28f5565760019b0f5a449972bb85e5faf35f0e7760578f42 |
|
MD5 | c2065d27c62a2705d4aafc8f7b69b719 |
|
BLAKE2b-256 | fb57503810343cea48df3978ac4b34eb132c10204f0efa2a695d74c49b183004 |
Hashes for python_rapidjson-1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70ba16319063098a034d6bc601f7ad356631a1fd550827e4b239805d38cbd455 |
|
MD5 | 527b973f9f34dffedcdb98e7cb2f1ae7 |
|
BLAKE2b-256 | 78f522f89d15cb5637e84387d0d1d12d5dee8ff18d5e7f749d78885510e8ecb3 |
Hashes for python_rapidjson-1.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35a908a129bd14fd4083784fe2db23368df59cdcbfa78f1f7d196665f6c40efe |
|
MD5 | 554a70f8c69ad07e1adf6b49206b6a7a |
|
BLAKE2b-256 | 6907c392b6fca88f956ea4d46c49ec2b6fcfda930e80add4f9453b7239652f27 |
Hashes for python_rapidjson-1.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b08623e4069b1c71fa45fa95eca094f190e76fb176ac38a3682a0f2fcfe1752 |
|
MD5 | f5df1f21d30d9ac4e62ef11e54328e47 |
|
BLAKE2b-256 | 3bbd87205dd0dc3624ff919e567a32defd809392db9f9f65b4071d4b7cad9368 |
Hashes for python_rapidjson-1.0-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72cc744212070768903417948cdc8e0432d52bcc2fcebd7ee3df9cb98fd37053 |
|
MD5 | 1755a37bc3de95b83f51c528c9d4b2c1 |
|
BLAKE2b-256 | e1931ef3ee3f50967be51c13c8e352d3a207165033313c4fea14f32fbd6800e6 |
Hashes for python_rapidjson-1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d16d27a11c0c79cdf1b708221fe462abe98f7a3832a0b7c4e066522e597062 |
|
MD5 | 50c23d945e89d0ff0ee258b6b91d9bdb |
|
BLAKE2b-256 | e65bf087f77183e187f09760951de1de4ad90eb712bfd4b9bc614e29a32b9673 |
Hashes for python_rapidjson-1.0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb53b859c62a5b123495603319363b9a9a4a43d7823e1edaa72738827251b47f |
|
MD5 | 166d254cc3c6c6c444bbd08c34d63fe0 |
|
BLAKE2b-256 | 98a723054ce10a301eddb8a77328a4aba952c97927c5faa72a7a5763fa30be2c |
Hashes for python_rapidjson-1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67a3487721f3a3bc1455eaf83e4e1bc729ad5d502f4b40b8a70f8893bbb0d6c6 |
|
MD5 | af07ddb7a9cecc1a77f80b662508fd55 |
|
BLAKE2b-256 | a63e8538d7c9991a016cc0f5d6eeae3dd51bcfdd0cbe5533fe0e161e003bfb11 |
Hashes for python_rapidjson-1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7be23a005e6424ee4336faba44f397b116aefe8ab7e3f3e33e2f4a7693469b0c |
|
MD5 | 6dd59ecc54feb106a4389906f0231691 |
|
BLAKE2b-256 | 9cf516acf2252258e34fc5177939368c522143517c533f185e2d8bf1e92cc94e |
Hashes for python_rapidjson-1.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c995c3e89f77baf72b814e941e355bbc0bb146b14c8cf75ca30f0f7788533118 |
|
MD5 | 53c5ae593c5cb0b6e0128b64a6939bd7 |
|
BLAKE2b-256 | a9ba63dc1229486bb281bee9e98b868055387af3beb29abd71d01505da985b2f |
Hashes for python_rapidjson-1.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eba0f11e39b5a3819c92f7c8c02a238d8784aa04fbce48233025712d5d32da89 |
|
MD5 | acc7e8e7607a071687162f1638ef417b |
|
BLAKE2b-256 | a08f50488049033aba6943659d7906a45947ea5b510b74e7d44ab9d7457e1710 |
Hashes for python_rapidjson-1.0-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d73bae63c0b41c6d78ff983a9e97bd22d745b49c96a52edc5e6a3ce31cd4c5a |
|
MD5 | 169266b9af732045a038d76acc161f23 |
|
BLAKE2b-256 | f5b1166836c148ded2acec7f822d53f7e1d79576ef15c5236b8fe706b5eba23c |
Hashes for python_rapidjson-1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52c663fd947438b640fca0a7d1b51b0f21de550f0e5c3d649f8cac0090ca4898 |
|
MD5 | 15a2794178b33adc9445e402231a6762 |
|
BLAKE2b-256 | 581708eb846ab5a514f7b162909a432e56d2f2aa25df5fa3b38b9a4e9e66b481 |
Hashes for python_rapidjson-1.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 139faed875bd794dba93a051038e450b52d0988a6c0b07cc1aea49627176bd4b |
|
MD5 | 519f7ee0cbc1c4f6a062b2f682e70c24 |
|
BLAKE2b-256 | 53d200536046567416b7884c11b4ec439f4256c0f9574f316b9ea6ce25dabf4e |
Hashes for python_rapidjson-1.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac728d59984e556ed56e59f497da4281bf96eb84bd035a866621dcfb90656ce5 |
|
MD5 | af31775e9fd881b3b89aac1205e37b21 |
|
BLAKE2b-256 | 5481fa9b509c4cf7ef327094302232f2e4d288e466d332b5800a16ee9906bd8f |