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
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 stringify a True dictionary key as "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.
- Arbitrary encodings
json.loads() accepts an encoding kwarg determining the encoding of its input, when that is a bytes or bytearray instance. Although RapidJSON is able to cope with several different encodings, we currently support only the recommended one, UTF-8.
Changes
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-0.7.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6dbe9c4c66be952aec3ae81b45f4e34d02b7bd47e57568a99566ae344e9befc |
|
MD5 | 427ee7e649eaa7a98d1f3ca8735193e2 |
|
BLAKE2b-256 | ea4dd76a1c49fb16935c032792071a3d63a09746d88ac7c1d9ff41f3d494b768 |
Hashes for python_rapidjson-0.7.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 525eebbb5e9e9957964c68c897a1181a2d42e69c109553e96ea43ba3dd78c360 |
|
MD5 | 2d53c3d2e64dd6696dfec5857f01ab43 |
|
BLAKE2b-256 | c3b922c471d15ef120f81168350543c00477181d0423331df1608cde44d14bb5 |
Hashes for python_rapidjson-0.7.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29508627db1dbb4b2bbca89d430528c9d270f631c6b1457ddb82f4b4f11fac05 |
|
MD5 | fda8725f0b99d62020b8f25a51cbbddc |
|
BLAKE2b-256 | c00d70b4ee9144bd70d4be3be93d2e8d55066f8cb52e73297f9c865e9adbcc13 |
Hashes for python_rapidjson-0.7.1-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 387f0d3b86647f60b4a6331eebbfffe95b637ce0d568f098a4e6ae01ceb3c368 |
|
MD5 | e27c7a4fc0c747f12c6b70db6072d130 |
|
BLAKE2b-256 | c662163cd25361b0594294bcecf8f436310ce271845e9e17079603294821f1c5 |
Hashes for python_rapidjson-0.7.1-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 022492d5fdb36cb424608cf891549149407c7aec672fe60ba461871850a46f1b |
|
MD5 | e5d765d262dbddb95d5debd876433101 |
|
BLAKE2b-256 | b88f179c0db624a6e54db2f71ebcd6ef2d9d7ea5e3c3f5e8566878837dfe8818 |
Hashes for python_rapidjson-0.7.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 769c33a3aba0bec3b2b3721d05c5958879de70b22f0d73755f02386a39c84a5d |
|
MD5 | e58b80bd6ab685e84f71c388538e024d |
|
BLAKE2b-256 | e16faf31eca64ee05e2a2e9ba15d8eb0db2fd526d2442006341b0ebd090a1245 |
Hashes for python_rapidjson-0.7.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f784416aff3babbb0aceec3ef12593c055749d64c24f0dbf546645cf8ac7cef4 |
|
MD5 | 2ead0800e9bbda41dd3ea937957437fe |
|
BLAKE2b-256 | 689fe7de04f5c01656d64fd3a1d1b0632a53fd6c183bb34644e6589073ac6638 |
Hashes for python_rapidjson-0.7.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0118e15a5420c1eb777da512b15e7cf7cddc599c5713d5c728fba1d9933ba1e6 |
|
MD5 | 90a7fcc7de3923b107dc1fc3b2137ad0 |
|
BLAKE2b-256 | 9250e7bcf9df3643f42de3b4f6cc5ca72c68fcaccb5f55a0cd9c9007bd993b05 |
Hashes for python_rapidjson-0.7.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee2abb07820b80c7bf7c752fe51580c14e3d1e2ba75bb8fb7beaf69be56150f9 |
|
MD5 | 92012d42618e84f38cf2df5c457efcd4 |
|
BLAKE2b-256 | 3fde174fb56d6d3e1079d4b3394bda6000269c5f5fa7069469bf8c3fb65f8756 |
Hashes for python_rapidjson-0.7.1-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b0a38f42e65d43415b40394d8ff9a40f7114e4221573df79f3f6f4177773306 |
|
MD5 | 58b214b8f0e29a423412c7986cc57a53 |
|
BLAKE2b-256 | cd8350d6b503213100aa930239d8487d57b5bebbdde880913fb25c32804e700d |
Hashes for python_rapidjson-0.7.1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4685de2ce614aafbc69838eac90500416f576bf37c62c26d7a543fc828b6a265 |
|
MD5 | 55976df58b78ed6b5ddcffd09249357a |
|
BLAKE2b-256 | 00594d1144603230acf983959874678486d38ad2aff0ace8e6f3b80b21ecfcb5 |
Hashes for python_rapidjson-0.7.1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4d349d25c4c92d193e892e8368d67e13dff9e1ceb70c4b1f5f112add860390e |
|
MD5 | 0d7e1bcb7d438291a0a185425b3e1891 |
|
BLAKE2b-256 | 9f3bd69965222f6d220ac28ed6c9b1e3b6f4bf6e2f4e4bef6ee3b55b87564c77 |
Hashes for python_rapidjson-0.7.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eab4c2405c8a12ce57d005c771a758c12344e34793396e4d495644fb755f326 |
|
MD5 | 9ee8771fce32eea638b0f6299d7626af |
|
BLAKE2b-256 | ab04a788060cc2a59f0a1817a521e72b22942db40b844220db0471a94e2950c4 |
Hashes for python_rapidjson-0.7.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 475820d98d0a4e039f1185706c795e993f3a5b3bd2ff48b4d823bb9919a607db |
|
MD5 | 2147d50564079eef86263628950e2967 |
|
BLAKE2b-256 | 3f3e121a3fa41e7bc141f0234dd73cd38f12247daf409bb5698d849b531bbd3d |
Hashes for python_rapidjson-0.7.1-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2492d01e49f642f3ccdea38581e824283147f28bfb4b3de9e5de1646cd156a3 |
|
MD5 | dad4a67514e8c516cb00aaa9de2fe2a9 |
|
BLAKE2b-256 | 180103af435d796a34cb8becfc4429d1bb777f15d4c22c0e50f4d9f4435adbb0 |
Hashes for python_rapidjson-0.7.1-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d23b1336f5083f305d75430000b3f9d93b8898e7443c3ebf4ad48a5a2d3f19f |
|
MD5 | 41be81efb35fea2b895b0eccc3aefee9 |
|
BLAKE2b-256 | 26cf7a84d97caa2f69c4df47dc2d46e904aa83b476d6651a6a465e2b93f9f79f |
Hashes for python_rapidjson-0.7.1-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d7dea19ad185f6535683c2110554eb7e0f5d4573c7807242b7ec259c4fec2bb |
|
MD5 | 45b17d623837ec2bf3b52e69afc773dd |
|
BLAKE2b-256 | 240f195f762f684911bfa019f55e20500eba5b53da3ea9a84dfffff06b8165e3 |
Hashes for python_rapidjson-0.7.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b43817f46325df477245581d57639dd5c99e42c9f915b4251823b0a9ca58b3e |
|
MD5 | 93bece7a7d516744f88ab95b68ef3626 |
|
BLAKE2b-256 | ba540ad7bfa8efa960ec2e67dd9e6a097ed1f18d40ed3d653f94149c242e1625 |
Hashes for python_rapidjson-0.7.1-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ef21fd3d8c18a278f6b2fd179ef102cb96a1e96161f64da4811a7ccfb8e6609 |
|
MD5 | e970c123da09302c7cb74c327f4b65cb |
|
BLAKE2b-256 | 3780b6ecc5200f3314d9655bb7413738801bad4d398047e40f26fdbec6bfd394 |
Hashes for python_rapidjson-0.7.1-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 313e4287de28669d58eefdbbbf095170715b0729f5630aa7081799ab573f0426 |
|
MD5 | 468f4e70e272e5b787a8f04bf1db7dc8 |
|
BLAKE2b-256 | 0d0711fde60502d7dbd962c5cbce6eb77f8408e1a1c970d3390db851561e86ed |