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.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 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.9.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ee8f1197cb056b1c74a6c7c557a07c8a92ab36f5e5dd88bb4dcedcec801ab9 |
|
MD5 | 95d8df11a3f0d9216df354c669f63763 |
|
BLAKE2b-256 | 0228540c1e5053730fd2b750af237c77b7712c85fab5113dc323aaf286b52806 |
Hashes for python_rapidjson-0.9.4-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 179a25ac6d4636f45ee4e416eb03261f625d2835d46e389035bbaa04f4e20155 |
|
MD5 | 5c6608b3d81b11ac94d4bfbad8f9fe80 |
|
BLAKE2b-256 | 9126b43c36ce3fdc2fd00e68fbe415d14ef59048adc6f0d35518ba1ab2628230 |
Hashes for python_rapidjson-0.9.4-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d472916bfa1bbc38a69e82b89d40fd64b3167ae8fd9c993992eb61871bffcc76 |
|
MD5 | 7260488c603aeadbe688f97b85ab0569 |
|
BLAKE2b-256 | 09a0066602d80f9dc326d21aea092129fb6435a4e18f3183ae896717c290cabd |
Hashes for python_rapidjson-0.9.4-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc0ecafb0712ba8c41687874ccab5de3814b09ea45061eb1a0260a54b645ca2d |
|
MD5 | f95d2122be5ca6b2863c93081efcaa05 |
|
BLAKE2b-256 | 17c1d260607aa4b17cd433d1940371d7266c949f914b952166b08127f640eeaf |
Hashes for python_rapidjson-0.9.4-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63afc14f3429f269c75d7a660d39e7267c16e85014012179443c1cdbbf281c1b |
|
MD5 | 35c44fa5c807f88ff3d9bc99451f47f1 |
|
BLAKE2b-256 | eda014bb9fd9ffed26051cccd6ee96006ff212152d66c23f43864616814d1e2c |
Hashes for python_rapidjson-0.9.4-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc663ff0e4c9bb39aa97d364a07248bc6c2f96abe54b62f295210019640d4da6 |
|
MD5 | 540c7ab74d9d3630bcd2cf7bc4e74aec |
|
BLAKE2b-256 | c9aefdaf7d24ac44887a677e0b34e51831a90e63d24cdf93ea9a574befe7921d |
Hashes for python_rapidjson-0.9.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74adbae2c0aa87bd9038fe8a74686a8803226040ebef773f89cb1153e482c3a8 |
|
MD5 | 16d399c18c8651f8ef2a6de3c595b0ab |
|
BLAKE2b-256 | ae2457e8a5f0aeedd3b9871eaf84f3c7fb98d46ecf79e6d57951c29451d6b44e |
Hashes for python_rapidjson-0.9.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 499275148ccf11a58b343c0234183d3a5ac74b73ecd54aaaf013ad314db272d6 |
|
MD5 | d4552dd53b27906ddd4107fa7c22b0c7 |
|
BLAKE2b-256 | cd0a715d29b06e00e8be3a2d0e5892717f3b90fa5eb03215f5f054a8fe3df375 |
Hashes for python_rapidjson-0.9.4-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71645fae033b3094849461b4597fc018d493a0b9c6234ba865c9a01b9c39af35 |
|
MD5 | be8edbf9bf230cf4d2b566881dfbca21 |
|
BLAKE2b-256 | 4b59d034d64c0e7fd18389b0b8ee5ab68728b49940646f980ab2b8dacf2cb423 |
Hashes for python_rapidjson-0.9.4-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3cd4c7bbdaab1642bfeb96f60815d712396af6a0deb4d9207a04d07937fcf21 |
|
MD5 | 6c5acfe6c2d9ad7e86e14d541cc2ba1a |
|
BLAKE2b-256 | f4e894b307bee8f26f6ce6fa94c80fed2dd545e57d411f46a2c8b63a37fd8ed4 |
Hashes for python_rapidjson-0.9.4-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1f30cab124fe77935897bb5f86c38bc5cbd2e262f3e4683377e05ebd40a28f5 |
|
MD5 | 10e46ffe2208229e506cb05fa62911c5 |
|
BLAKE2b-256 | 07e7e4595d4aa39d8ab08bf531c33c254fbf3882f4a2863a7605840f0090ebde |
Hashes for python_rapidjson-0.9.4-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e3c87ec75f22cef734d9da74373a6f89f6f16403889c4bdefd1a44bb17ddd86 |
|
MD5 | bab92e4aab981227b924b2c3ea7bc8b6 |
|
BLAKE2b-256 | 350b8b850d79da8a7120e60ef3b790a7438e0874e9744cbd91f91479a835a4a2 |
Hashes for python_rapidjson-0.9.4-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00d1bf4b1c1d35bb5cca3b2ff94ee6dd16c21c9b5b796c8ee409cde194d5afad |
|
MD5 | 8f3f54c4037c3a0c26780fcec78f2f92 |
|
BLAKE2b-256 | e1dadc26010688997009d7c5b3546e159feb61c4b3970ebdea3090314f61a9b2 |
Hashes for python_rapidjson-0.9.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5153c1215a5403f430ad4b8e93508db5c147cd0fa24ecb1531a47f181ff3335 |
|
MD5 | 7bdf66a172b8035661c7fad774121864 |
|
BLAKE2b-256 | 7d745946a2982c689a71be4ac1caaac5a401ae324000f47eb9e8b687cb3908d6 |
Hashes for python_rapidjson-0.9.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed95201266e238f0511e346e4c3e491daeef5a86af87d64de59d9ef0e9e6a038 |
|
MD5 | 971825d8635e2a2ef471f0e537c42443 |
|
BLAKE2b-256 | f61e81a3735872b35d5bcd7c7a82576570d4a2ac575bdb59eb26d26eac593520 |
Hashes for python_rapidjson-0.9.4-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bab0ce54fd77ae91ae039df80e81ccf4a0e609e403cff10f671aa1764c78c394 |
|
MD5 | d6c965665436df38b8cb9a64de101f96 |
|
BLAKE2b-256 | a34afc745482ecaffdbe85c7caa65be5b700ca346fd6a0f36e3f7487004ee944 |
Hashes for python_rapidjson-0.9.4-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c21cbec503630d96111b9cff34a52535f1fb862833e05fb67361af0330aa912 |
|
MD5 | 44e2523879d9c5a8fdb781942146f31d |
|
BLAKE2b-256 | b70de3383fc493e1e689ec110bc6bf72e2ae099c0d039c8ff6436bd78ea5c7d7 |
Hashes for python_rapidjson-0.9.4-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 851c7673caf2a632605005b111181ca7e8b8fc81cd194679bd1a168b3c0d9939 |
|
MD5 | 60fa9a216cc63e4dbe8dd9430eb57ea9 |
|
BLAKE2b-256 | e6ab9f47d31d47adfe324a67c393756533fa97b819a752e295526cb534a2632d |
Hashes for python_rapidjson-0.9.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 281e984baf634b834ee42eeeb964e30bfbd75bdc19dba92a4203b362f31304a2 |
|
MD5 | def72f9f3e8fbc01da0db7f376303436 |
|
BLAKE2b-256 | ca40b75b3762d7564f1870ad5693dae4c0fa0e5804db342e0f11dbb12295e3aa |
Hashes for python_rapidjson-0.9.4-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bd403f317eb1a809a1fe6f3a16a7260576a34b2c9f63bcaed0a88e42ec6b461 |
|
MD5 | ef0f379ac2a63e269890c9ceff75a96e |
|
BLAKE2b-256 | 63fa263a39b6470ec0492c8dc06cb049a10fbb48837d02491d8e8b6d422a31d9 |
Hashes for python_rapidjson-0.9.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee2bc51caefea14d18f7924e0ed044f944d5cb6d8b6df4e0859b3184cf951db2 |
|
MD5 | 4181d5a261f1ed50d51eb9368496b667 |
|
BLAKE2b-256 | b99120a7be11c6e55a54a264ff5979a884b68bbc4af19f616d1efb7177794e17 |
Hashes for python_rapidjson-0.9.4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f178e6339f999bfa18767f126829240bb37d807d23d464fb825328881897bd30 |
|
MD5 | eb9c49550cb59376fc1f6a9472457533 |
|
BLAKE2b-256 | 824221e5277da3b685297e7b9bbbe3f6ccb4971bafdc7a72d283ebb9edeef824 |
Hashes for python_rapidjson-0.9.4-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cda761eb0c77f602c5add2bb5ee01ac733411b2555f2e349ab55c5050a2cc2f |
|
MD5 | 5c097e98d23d930c8cfbe6bcf09cc247 |
|
BLAKE2b-256 | 6e376cd23065bf3e85b6ce6cd99543447c0bf7dfdd8cab97644c11481cef0f2a |
Hashes for python_rapidjson-0.9.4-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fc1ebd39c67e6ef41f8b4d8a000b7b89af37bde68c3ad0f6b7484675fcb3399 |
|
MD5 | 0db8718bf31f04cd1bef2203b8025cbf |
|
BLAKE2b-256 | c4d0d235aab29c8f5c3aa5afaecda996d53a38cfe8e78d9641428f2b0642fa49 |
Hashes for python_rapidjson-0.9.4-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e4efb9fbd993c1dd1302b7306ff72e67e9da884391958e7cc9a29006abc50a0 |
|
MD5 | e255a6fc1391dfdcec28a488cafc5b0c |
|
BLAKE2b-256 | 062730ebfde4919fbc1acd66229f33a20199fc6d1cf810f65a591993a93ffc5e |
Hashes for python_rapidjson-0.9.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0f2c1866f9b925e2a692075fc69372ad158062faca395116ce7f74af92e7717 |
|
MD5 | 06c4d5eaa2bbf5f778b19e13299a6de0 |
|
BLAKE2b-256 | ad5910a4f2d3fb8c001eb1db587cc0d2bcbd378ed606545465f918312330cab2 |
Hashes for python_rapidjson-0.9.4-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c8f8336b50f925ec37a9c67b2b041a64be02a1e28a7465d6dbd38faf76f06a2 |
|
MD5 | 6029386329221862934a1f724dacb0fb |
|
BLAKE2b-256 | 927ee145e20614308505e3a85a289aede5626c736bb826b0d81a842e95a31589 |
Hashes for python_rapidjson-0.9.4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38969854e7cc40372f8306c8fc5c63e2f421c796fb5dd557b3a55bf200a4d998 |
|
MD5 | 1ebb3edd5d00f7a88be1c9144db83777 |
|
BLAKE2b-256 | 02652143fbdc0977bde6c40338cc821742a3bd89b84a29bb0fd8809a3ffb0c3e |