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.8.0 (2019-08-09)
New serialization option bytes_mode to control how bytes instances gets 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-0.8.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea83e31069debb458672dc25c9283da154874713829f568cef88d998064dd0d3 |
|
MD5 | 93d1477a26430c838cf8b3865f9b2df2 |
|
BLAKE2b-256 | 479364ce06479b1b8a291584ad0e52ef8a91c4a93291568aa4a0ae406ece165e |
Hashes for python_rapidjson-0.8.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59364379a4108d95aad9c2ab84705cbdba6e8b1b0b2d70dbd5430e3c97f691a9 |
|
MD5 | 5d102843c0558fcc96be16f75f26ef46 |
|
BLAKE2b-256 | 4c5c5166c4cf25b9c4ad5aa1a0e3790b5fe4137cd79a00c4c56d5f0e98a01292 |
Hashes for python_rapidjson-0.8.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 204d38a959b23df83f8c7134d9215eca5e71bb39b37222a8f373f5d465d7ed1e |
|
MD5 | 7dabbf207603a68dbc91b52e12f0afd0 |
|
BLAKE2b-256 | e8fc1ad95a456d890fe3f290642d5c1d1910da49b86825fc8abb1d0bed454997 |
Hashes for python_rapidjson-0.8.0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd25811c3737ba364542bc9803f358551e6a996abd0a3e66553e026576b219ee |
|
MD5 | 6085ade0ea05812849e0643a8b98434e |
|
BLAKE2b-256 | 9de0dba02bb50808225355557d0959b75da165e1b21665447ec0c968092ad55a |
Hashes for python_rapidjson-0.8.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 316d60ba4cda1b9e10e1983864b8c63472f67639f27eac3de4535c8f4a082e23 |
|
MD5 | 4cb38160ff68b805d603d8fd137cdd73 |
|
BLAKE2b-256 | 2a6ed909c50de9768ef20a0c014b7f054662ef80d3c8cd756d9cbb92aeebaf6e |
Hashes for python_rapidjson-0.8.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d569115c7dd81e2255a8409215dbc8083e56ab4e1619f5b3646790ae8d198933 |
|
MD5 | 38d31d214af707d43fb0d70bb10e0745 |
|
BLAKE2b-256 | 8ceb7c511dea80d0e36e5dcd2047e1dbab264d7369b9721ca1428718d5e35a0c |
Hashes for python_rapidjson-0.8.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6add37dcbfa42f21bc602f203f4427274e0b651e1f0f8aa02ffd9c5367031b5 |
|
MD5 | 7b802e663e9ab1ab58a5fc007b0840d6 |
|
BLAKE2b-256 | 398d507f5dcb6aa7afbaae90f016889c1b6b20795c86a631c8f5028597323273 |
Hashes for python_rapidjson-0.8.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd546fe7a28d756840d8b88d84e813d5f4ad410d47680039f3a544181141289b |
|
MD5 | 4a42435b75f42cba04b905c44b1afdaa |
|
BLAKE2b-256 | dd327da92d409426dde28cdf844e7b1df1f8a5a790e0d53b45b850641946ddd6 |
Hashes for python_rapidjson-0.8.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ee4f987010889c32cb68731cb3e3595a249ad549b0d00ccc78d4453dc0703d2 |
|
MD5 | ba62e3410eb56dd36ade143d57505d92 |
|
BLAKE2b-256 | e18528d69c0b41d3ffebdf75c74610626d3f89270d031046518c87e4a32e8024 |
Hashes for python_rapidjson-0.8.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6942005bed4be7fb8fd04ff691d93fc19640da8dbe6c95269a8dbbc9350a720c |
|
MD5 | 727c54ab96271662bb999ed1fb5df64d |
|
BLAKE2b-256 | d59507fe05c60b3333342516ff4330e4ff6240d33ff76811baa1ff1d15b5da1f |
Hashes for python_rapidjson-0.8.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 296701017be311ee8fb8ed3ad818b6141fe56f7fbf664294aabbd07d5d52b373 |
|
MD5 | af7f7884ee7a4983535d747337b16749 |
|
BLAKE2b-256 | d4096cab22d58434a7f79ac60e31068acf639995a5ba4a2d9abb463f7659ace8 |
Hashes for python_rapidjson-0.8.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 185309fd4cd7ee913303e75646571bc63797b31e73181b6e5db4706efe8a4af4 |
|
MD5 | b5a26630c62c923e90d0be2984ea93ce |
|
BLAKE2b-256 | 663dab1ab68dd3d2c4b4691a95572c2b8afbe8ccbde76684f7e65e12964b399d |
Hashes for python_rapidjson-0.8.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 402fe264c53d25b8c59a1bf476f37c2b12252a956067cb0f43092829c4907ff6 |
|
MD5 | 39e57061c082a21e1296736eb8b35c39 |
|
BLAKE2b-256 | 58f64c08d6ea3b639839ba77af74706f6bce4e9286304b8d85296507e5b09cef |
Hashes for python_rapidjson-0.8.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27f852fa8e8e644ebbf0bc6d1fcbadecf4304c8e0cc1a52c48094150488dc14b |
|
MD5 | 5c439b0df40a308156be6eab6d0d5a76 |
|
BLAKE2b-256 | 29286f6a9a576c76571cba0daeca5bde5f5bc7ce06673d2fa8d78b8ee4081c09 |
Hashes for python_rapidjson-0.8.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67fed890718a2475fd3f31226a3575959936ae010b16739df257f99936c14d76 |
|
MD5 | 80608ff26a31e2a41fb3d458bd37a658 |
|
BLAKE2b-256 | 8dd83dadaf728aff6db9b9289aaf8ed5b758ee89d7fe9d4fd5ddf9da14d3d59e |
Hashes for python_rapidjson-0.8.0-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe0ce76fc0e224edaede0e02fa480c0aac10825503a466fe72c3c0a99b60f9df |
|
MD5 | b22b25ed8a2560e634a9c35e2a56f270 |
|
BLAKE2b-256 | 929ea9403c6ef574a04cd450267302b68e9832da29c48918f989fa7fa3270736 |
Hashes for python_rapidjson-0.8.0-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e36bd2238b7a8d02cb6cc916bb1abbc048a02432039bba76cf7faa55862f5c2a |
|
MD5 | f251347b646d7a80a3c6d40d9c8424ea |
|
BLAKE2b-256 | 3c81f9cf78eaa31e1de5289401e65c1e5fa8b142d79b6b088c7db00deaae28a8 |
Hashes for python_rapidjson-0.8.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44cec74783acde5b5b1fefc0e2898cdaec31b3c00b567b338df9cf780a9f8476 |
|
MD5 | f9d55c71d29a0307b7a357c2acda0ffa |
|
BLAKE2b-256 | 5cd89157140cb41a27a3cccafcfb351784a789a5691d725ebd171f3aabf17b08 |
Hashes for python_rapidjson-0.8.0-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6abde898f86eae47b86b1142c8417e30c823a442479e435855aa15046ed63e3 |
|
MD5 | 9ad99197bfcf7df1b8572e4002d55bda |
|
BLAKE2b-256 | f0f127ef1f94091dc0e94e3c5eac8c923cf910b4e0ead69420e5142e24306a6d |
Hashes for python_rapidjson-0.8.0-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b01e1cfb3a1a3797ce574aa6f5aaa7a29023c300b4f0969571b9803bfd4627c |
|
MD5 | e003a6db08b0e62c89f46269ddadf566 |
|
BLAKE2b-256 | ef94e1b9958b90142e98dfe02af1f2dd1ff10600eceef00f1c47673dfb75628a |