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.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.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8e3b955e53cfb3a487e424cd1317a4bc515a49a9ed45ff8669446250e53168f |
|
MD5 | 7ada59186fd500670a83065fcd097628 |
|
BLAKE2b-256 | 4e66f0dad4fb5da873a8036cfb6e5148b95f6f96cb6f2b2c179fa455c61d5348 |
Hashes for python_rapidjson-0.9.2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bb1bbf81e8b80711e086d5ce2cc7a4cf8b57be47b12ea3866409ccb0670b3cd |
|
MD5 | 28cbfc5f24836e161f95c3b803ba022e |
|
BLAKE2b-256 | d2da84fc8729ff665200d625b73c6187f961f522392d2319250a84c92140ab16 |
Hashes for python_rapidjson-0.9.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cb5f8148afbef6c8e1a76eb0449b51a103cf8910e06d74b9625fb465bc0f3aa |
|
MD5 | c7d6e3c002007cd36ae0aba87e4df591 |
|
BLAKE2b-256 | 5117297c67a77ef4665f7ab1d18e756d17c6cc6bc30a6cfbb1bd43d0cf803758 |
Hashes for python_rapidjson-0.9.2-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af7d0d20d8f8368fe8f9e0062b189912979e61ca55d126bb0247b76d08004257 |
|
MD5 | 0bb3576d205e067ae25b38ba85623312 |
|
BLAKE2b-256 | 4ba84558f1bca58c8491ea54442107edb0e37facbf59bd33baf62c8443116a30 |
Hashes for python_rapidjson-0.9.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a826500a964300fb62eeeb1213f7f89e360eda271010dc096d8b3468c62be24 |
|
MD5 | 8bb90d30a2658c6605ac5c3ecb6a4f3d |
|
BLAKE2b-256 | 47ad28eddc3bf2bc72ff79ce2e283c735f5547db835781eb268210e9532ea3d1 |
Hashes for python_rapidjson-0.9.2-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 861d6f84cf464bd368a29d36b68fba201e7f711ec1fd8ad244884f77ee21f291 |
|
MD5 | 9570d9f088820e3cbf3b50b67ff687c4 |
|
BLAKE2b-256 | ddd9e4cc6dac320e5dd00ef857669b6f620ebdde7376979376ce935b518d6959 |
Hashes for python_rapidjson-0.9.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa95cd6451959819fc44f6175939ca8272a4feadcf0360b271621e411744c958 |
|
MD5 | 3dc8686471176c4482cc329220691a6e |
|
BLAKE2b-256 | e43d2c5eaa46e3828b7b5e9d4bb7b852fa4c1d6c889a9445d602b0923838621f |
Hashes for python_rapidjson-0.9.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7ba2280615581e7570b2968a18ac2f55dca994fc2c4c0786e74ef012e1d1f04 |
|
MD5 | 61152d0b6112fd226c2f42841502355a |
|
BLAKE2b-256 | 35601c52ec388a7d954e7fd333b84c8db0c704b08e515f11b724c55071688dd3 |
Hashes for python_rapidjson-0.9.2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3400dc5e8714057f9edaceafabe6fdf4fe851e92fd00874014eec1f90a859986 |
|
MD5 | 5ba1f043a2916d934ae95a2671d6754b |
|
BLAKE2b-256 | 7e6b7779d10bfa60513e6c85ece73d209aba4731905239bbad0b0078a3c77bd3 |
Hashes for python_rapidjson-0.9.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa5e4c5fba1e0515ffdb0a9abe9738fc5c38648fea76dbff6a016e2b2de6e6ab |
|
MD5 | e9cd75958c7cc5e3619803924f30db9c |
|
BLAKE2b-256 | 2dded0d43b51b2bcb64a9f9c39a54f3d92df78192e34df89ac4ae9dc419dab26 |
Hashes for python_rapidjson-0.9.2-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ef5d6bf8c2e3271d2ca2995612dde13c5a3c6f0c6efae5b4d8504c683a2b786 |
|
MD5 | 873b4ec43949e6382610de99c4819f2a |
|
BLAKE2b-256 | 498614628bbad283e99c38c249645e5165f1463f854b6904eda4d9b9f2802e56 |
Hashes for python_rapidjson-0.9.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81b9e417f19b8a5598894f55a4b81220f4e0fe6c68a2af32b152205cde8f7ffa |
|
MD5 | 3f675d4c6ee81f78684739986d586f1b |
|
BLAKE2b-256 | cce8158447568a621fc29f79b2d1bfb08f0895afed6028a46be95960765242c6 |
Hashes for python_rapidjson-0.9.2-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e74115dc49921d679c227faf601bfe80dff18e18827f5dd17a2f5ac0c5b3f86c |
|
MD5 | 9412d5b0540937b47bebc23f19ec82cc |
|
BLAKE2b-256 | bb99fa12f1aadfb7be892eb04b6acd7ea6ba59d7701736f812025c764e57eb83 |
Hashes for python_rapidjson-0.9.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04c3d3897fce3685819edafda5c2813143d271391ebaf37aea8fd81277e830db |
|
MD5 | 2c06d71df9e7da1fc0338e21ceaf2865 |
|
BLAKE2b-256 | 76b97e84c4a5d24a6b4880ba72526d71ab7c0052ccbcaa44eed0394d3d82664f |
Hashes for python_rapidjson-0.9.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3f5edad3206fadfb127c5fe5ca637ecbf34c7589a5e6b23a04f6dab707e0224 |
|
MD5 | 11b7c8e9166cb19d4922df79b18cbf76 |
|
BLAKE2b-256 | 62ec17da921a557db2cbe2f8ea8659bfb2f4f717aada5893f85a1861947a7b27 |
Hashes for python_rapidjson-0.9.2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 714e5a2d77f7763e605591c67938af2e9316ce84cd2423f88913c5b98d3cf414 |
|
MD5 | c9fe5837f3cfdb14d48ab193322658f4 |
|
BLAKE2b-256 | c9ef6e1c932fa2e131910ef7d68e4b03c39f1ca4a2f9a1610ed69741b9703fb6 |
Hashes for python_rapidjson-0.9.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0973d9ea200ef4d723e042ea3480b14bc7907b0cc8aae72a721fec7ef90838b1 |
|
MD5 | 933f17fd3d03a92e99c0efaf4baebb31 |
|
BLAKE2b-256 | 7b8bafd93345f5814f0c19b5abdb089e0880ef1fa9329855ca56fb7e650b28e1 |
Hashes for python_rapidjson-0.9.2-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c33345cc21fd4944575a6e26fab70a10c36aac8468608b4ae4fe543c73a61bdf |
|
MD5 | 118e7455e6ec429374938034943cb7d3 |
|
BLAKE2b-256 | daed8134f4eaff67d285676db83913663ea05ed8d66b7ff85420a0fecb541c54 |
Hashes for python_rapidjson-0.9.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90763aa61e48069994d0a3112f368731b5f4b871d9a6232f70db429801880a8d |
|
MD5 | 086fd6ca6fcfdfd6e407e69b7f695549 |
|
BLAKE2b-256 | 700ab202712cd0f449583d7b2d8a86b94df2fcacab1b156e56c0076c5f16799d |
Hashes for python_rapidjson-0.9.2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98f177c452c4ef60a331f5ebc4e3266a53cb6f770dd7482466c86312d556b7f6 |
|
MD5 | c7d555f9f3fe0aa837c751faafc4e739 |
|
BLAKE2b-256 | c8d76c89cceb6aeace97807f6104beffcb0232e0fc655d3bfbf16f4012e63919 |
Hashes for python_rapidjson-0.9.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 248d82d716bc0691c0fc1d1c6fa9d25e76ecf9ca7bf35481e1be609f80c7317a |
|
MD5 | ddeaea25b65f3cacff2a875fb3f20b2c |
|
BLAKE2b-256 | 7b5fbcf905c41257f9c3881a3b7fa0f52866c9ed686f58ecdc41f932991867a7 |
Hashes for python_rapidjson-0.9.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e222aea57129e0823e612d91197d159a85b85e1602a1ce5e7433804e933d8710 |
|
MD5 | 9f55f411fad8f96cfb899ce4ebcaa13c |
|
BLAKE2b-256 | de139c3690fe28dc9970b6644948785cd22f475e83ee52a73bec191a9f4f2dc1 |
Hashes for python_rapidjson-0.9.2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceec6fce2fe932760cf1bce84853c13a1dc64dae65447559c75ce459584c45cd |
|
MD5 | bc0f3ba782e59f55028723e7a0faec3b |
|
BLAKE2b-256 | ac77d3fdeb4d01c6c9faf6d733ffae80d5c03f0ebf5b5a4c3a31f3a7dd7ce7bb |
Hashes for python_rapidjson-0.9.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e72a009f8e9e75436a676dd5db4e3db38e19b57e7f72ccf0d031bf99232a1b47 |
|
MD5 | 68f6d69ee1ea1896fa3e5b81a1e17c07 |
|
BLAKE2b-256 | 7614973daeee2d6f41a41755bf7cb79ea06b03fec3e32dea079ddec75eb6d5fc |
Hashes for python_rapidjson-0.9.2-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95e4e36f823d2c37edabf1d6db21eaebbe8584c29e5fafde483fd1fb75f8398e |
|
MD5 | d31f3ab2eaaac68681c63e236e5ab28b |
|
BLAKE2b-256 | 7566bde2a1a864c1e74909cec7132881fc7c4f3279016604a8f29c468e5d293c |
Hashes for python_rapidjson-0.9.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 791b83fb2da151f4739c7363446f94b830676f2a6f716804b4fda3eff9c57d55 |
|
MD5 | 1ea61ead31fddf1e7e1fe4e621d39b16 |
|
BLAKE2b-256 | 16acde0e936e250242329c378a227cb3fe684e26dccda315f8bb693115f505bc |
Hashes for python_rapidjson-0.9.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f16408bee53b56888427bec14eb19634bce0f27cc51733c0d676453291a55992 |
|
MD5 | 12d11f1b17217100276ac81105485da8 |
|
BLAKE2b-256 | 9ce7dc8dcf0013451af96313a8ca74b6f2ef0f92e599aad57e5c7b3599e6126a |
Hashes for python_rapidjson-0.9.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bae9d948eb5bb590c3434eecc9508ea01282ab2ee242a9dc53838d22a6e29edf |
|
MD5 | 69fc55f9b7bbd6c603315a306cbfac4c |
|
BLAKE2b-256 | 8be5502ec969a1c4e9429b43e64458983e4012567e73a76753901e9ae9136a33 |