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.5 (2021-10-16)
Fix serialization bug when using DM_UNIX_TIME in a non-C locale context
1.4 (2021-06-25)
Build binary wheel for aarch64, thanks to odidev (PR #156)
1.3 (2021-06-25)
Yet another attempt to fix automatic wheels upload
1.2 (2021-06-25)
Fix automatic wheels upload from GH Actions to PyPI
1.1 (2021-06-25)
Reduce decoder memory consumption by uniquifiying keys in the loaded dictionaries
Implement an alternative way of transmogrify JSON objects, similar to json‘s object_pairs_hook load option (issue #154)
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.5-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f378588baff7e3e7f1afb01de3912f969c727bdaaa7566c456bbebe3852a5e23 |
|
MD5 | 4f4057c717182f4c19e2c1cbc4ec9b7f |
|
BLAKE2b-256 | 6a365e2af3dc6220719e7161e65b2e1b1383eca9c16763e63fc1e1dd7101843e |
Hashes for python_rapidjson-1.5-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af53be06737fd20c473613bda7a7c2207b75f25a078a3d6cde630bd40b125345 |
|
MD5 | a13ca412717ca552f986e411628a75f0 |
|
BLAKE2b-256 | 5d2b02fdd01b9753dc79f468ac413ce3962b3899a603cf7fb7d463a2678b2764 |
Hashes for python_rapidjson-1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27b88d73a821f772d72d13aacdae229898f4c2e4d4fdee50f82128cf9974e92f |
|
MD5 | fd73ca23e31388b4ffd03e17baf2ebf4 |
|
BLAKE2b-256 | af1f2f235d0484bf3825f33a929cb84bf5b28416e6128416f4cf91e19ab7e6d8 |
Hashes for python_rapidjson-1.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75cbfcc038ec9db9c02322d3e43567183a1c3699ea223e8bd5082ce2d4c8a559 |
|
MD5 | c282fb27b0a9cb55a974f167dd3149b5 |
|
BLAKE2b-256 | 13606e317519719b82c3fff202ef8f282fd8fddefc4d794271064131c4065890 |
Hashes for python_rapidjson-1.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fdda4556c5c10f936b4e3bba14dd38becf8f861a536d2024b9d04ac200d9b4b |
|
MD5 | c5f37006b7879d3d5930b311c0af3fa2 |
|
BLAKE2b-256 | 4ac5b7c4d7939f867222e04cae2336e7c172d149eae0015141a551da8197a6ec |
Hashes for python_rapidjson-1.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18479fa7f9d23468f9b1eeeacd83698979164c80ce86d786024ac73480049e77 |
|
MD5 | 43eaedbadf0cd737a84e17032a5ef7af |
|
BLAKE2b-256 | 17993c74685bf894b5d104ceb30bfb921f3342331711aeb62a56de0149762be7 |
Hashes for python_rapidjson-1.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 121a787596cd3e1a4913cefab734dfcec635e9ad5b33d034728e28d1514e9068 |
|
MD5 | cad8aaca6767cddfb91b2d04ea25e25c |
|
BLAKE2b-256 | 98578272d5791bc213f5633dfe374b09420d9d4858f941aa00682c0b70fba81c |
Hashes for python_rapidjson-1.5-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3af7c7aad5b93913a2eda2746e1fb91ec8fc7e54596fe5b1a5740048bc4480f9 |
|
MD5 | 4882285005242e882d07abf1163f08d0 |
|
BLAKE2b-256 | c25dcd38628164a23511e0d31c375f4f86cc43bc12ffcfb329bb92b500308aad |
Hashes for python_rapidjson-1.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1ce13e7bd08b8fd9d8ef8dc20f153100afc5aead1bbb0e6f5c216bd4d8d8a31 |
|
MD5 | f6952ae7961c35027f543fd12af13737 |
|
BLAKE2b-256 | b15648f6b921bc3c77d2cb1f3f145f57140cda6c33a8b178e497ea8c86a4c9a7 |
Hashes for python_rapidjson-1.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f83c5515e4acc0cef7d98c4623a357f54c2c4833d918477a12eb595658b4fd75 |
|
MD5 | 44f79bb4a668ca839340b40282b80c01 |
|
BLAKE2b-256 | b923b1a5eabd5e5343b12c3566e94675920aaa5c6debbcad21321834e09bae13 |
Hashes for python_rapidjson-1.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c5a3df3539752ae544725f93e03250be82834f0025fe3cf95126d75acbf4aa |
|
MD5 | 732c754d344255e05f472f2a12e157ef |
|
BLAKE2b-256 | 479c92f5acfa12249d5177ad0feb5e26238c2b3293063b8fa2afde31c9747958 |
Hashes for python_rapidjson-1.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1121e0de5179b923c62b2da843d0f110d83880ad4f8f66acaebb88a2c8fc28d |
|
MD5 | ba558f1588207c91bd60440fdea220d1 |
|
BLAKE2b-256 | 300b7d8094f6cde88a9eef6398007cc55e82d9074956a0637329bdd11f413354 |
Hashes for python_rapidjson-1.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 869c58ca3b1e64fe9ce612c4a05d792c6e299a206e7efcb3eb4e5fbbad938e40 |
|
MD5 | ff7983922418075dd55488dda6d38f52 |
|
BLAKE2b-256 | 9f5496ac4f93bba95b24eb19610f156b577f859477b8b6c11b37497176cf8f63 |
Hashes for python_rapidjson-1.5-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0890330cea15a4e0e48d0257890c2bc4700ffbe4fd3ba3c459bbf0af3a86139d |
|
MD5 | f3ddf6118a2d454d0577bb3620eed0c7 |
|
BLAKE2b-256 | a14f83743182825a7838176325e433a4d8e9b6a83f390b8261b602649eae6d57 |
Hashes for python_rapidjson-1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd41c155599032aaf8c20604b71bd7f4109ef9400f8fcea04a155e8b3d3bc20f |
|
MD5 | 2a4cd9d552b37475d6c70c1520e181b8 |
|
BLAKE2b-256 | c8d3ad0bd226fbc61350bb42d682cb0e65bd041f226e06873f056174cfd054c4 |
Hashes for python_rapidjson-1.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459272d561d03b308fb2cbca4312955ae8ed7d13a81c5f2d5324149433d3299d |
|
MD5 | a0477761a0faeb8300f99c8de686f945 |
|
BLAKE2b-256 | 5daf32da889f61e0d48c77a74324018ed1b4bd4abb854370f34b617a7d67c5d3 |
Hashes for python_rapidjson-1.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 389eed04f81d8952b25d1ab45cd12103cbd014e9e0f9bc249157279da3669ebd |
|
MD5 | 4078284c0104d3efbfc5a0f389785453 |
|
BLAKE2b-256 | 52ec683a93cafb9a1764cff1838d6663a2b53c0bd39f815bd84ca39005ee69d0 |
Hashes for python_rapidjson-1.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55f948bdb73ed577f18054ca53c5ec92e8502f68894b51b3e6899fa259a6850e |
|
MD5 | 342b8b933c66795ee7d6ecd926441fc9 |
|
BLAKE2b-256 | 73312eb0224a3619b878b4ad9c59a4e363605e017a8b2774b13755125a97ef03 |
Hashes for python_rapidjson-1.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef8e16765ab230a958060c7639ae6617e720313faff2e5c30495dc1363e117d1 |
|
MD5 | b6cfdd56d72a89f264892cb51c9f5e1b |
|
BLAKE2b-256 | 70e3260d37d37a542beb4d073420d273961ab10eb8023753a99b353a07c94ee0 |
Hashes for python_rapidjson-1.5-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58ac94b595162d0a0c873456703dd851d850c9f6b07622878ad9e98215b1e5b5 |
|
MD5 | eb52e771123f2bfe675e4c7aad143081 |
|
BLAKE2b-256 | fce56f727d5d01fea83fcd0398c432a691d4350d82350ac87ea98b01e11c4977 |
Hashes for python_rapidjson-1.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0e7e6f5e01ebb72b6126db2495c7f898f01b02f92b2a2632ceecfa5d98e8ff4 |
|
MD5 | 96babb9c7eb654cfc8ace4ef8793730e |
|
BLAKE2b-256 | d3d3f7865bae91728a83ce18e992b0ff8bbcfda1996e4f18dfb7a6e9f9437187 |
Hashes for python_rapidjson-1.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94623a6a759b02b949f14ac11e15d49a6d0c78003a7966b711418a37b0bbc52d |
|
MD5 | 5d2b9cfddf4dfe2972708e49a0403fe9 |
|
BLAKE2b-256 | 05d289751cff82e9aff4a303a2b2c32c3809272bb5eee328b963b0bab572553a |
Hashes for python_rapidjson-1.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 133516839bb058876df971c1dc18aaad841c973990bde2b233a76953ccb5b0d8 |
|
MD5 | 9a9e9bde57ca33e83857405b5655e01d |
|
BLAKE2b-256 | 678ed516425a258c9ff4e9aeb576b6092c0cbf59c71713c8b23a9d3185d26264 |
Hashes for python_rapidjson-1.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92b25445e52230db0b9477a6c2238cf86ba08aceb8b1d026a4baa994dc7ecab6 |
|
MD5 | 07e24bcc1969597697326dd156ddba44 |
|
BLAKE2b-256 | 35417bc3aec9fd9b732a9bc5de8d1afca3eb561d2839dc1c18bb1a7aeeefc7db |
Hashes for python_rapidjson-1.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a743dab61e9ee1ea6e5abcf378ccd344b6c11dd80db583244ec7cc958c3e03c |
|
MD5 | bc48f1ee1a021d399f94f03fccd36ab3 |
|
BLAKE2b-256 | 401e35e1da9079d495b6d596f25339cc7e666fda8406fd78d9aa4acd9091a01c |
Hashes for python_rapidjson-1.5-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f179435686348fe04e9cf4edeaca25830adf5c73213c9f662888a53c2191e04e |
|
MD5 | 7bb05da7a4e5a085b4b5e244f25b4d8f |
|
BLAKE2b-256 | 3a79a5bcf7f5d38ea6eed7714137284a64f51a315b684ac2313f165a0fdeded5 |
Hashes for python_rapidjson-1.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | def01cf09efc6069e4d1b98702d02f8962c272624e8222f6c748e32f4a8adb77 |
|
MD5 | 4c1c1fa0347d966b40cc713f0065f0ee |
|
BLAKE2b-256 | c295755bc68632c969497b20eeb9dcd38fa73bc9a3620d9435d177064a1f91ff |
Hashes for python_rapidjson-1.5-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e865fc060d9542a3ba50fd7a76200b2fa83e05a6a2d16f23bb101b571ca0375 |
|
MD5 | 3ffca4181380c301e1bd532c5528e039 |
|
BLAKE2b-256 | d7150d2a73f4d69b85b76bd9e895ec22d7eace631089adb0c3eeb038e3ea8d44 |
Hashes for python_rapidjson-1.5-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d38230f20ece88147cb94af37a4822d8587ba44a32d5de1f49db10fa0e2dc925 |
|
MD5 | e16efb2ca4d65cfa5219aab7eda54ad0 |
|
BLAKE2b-256 | 228bbf001928f598ec1a8e84978b55bc10ce8c63ecd63ef1a8986e9e451a4af4 |
Hashes for python_rapidjson-1.5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf7c508b314d27505a607fd9a7298b3dd08cd44feb1c07d064c9fb24045639b7 |
|
MD5 | d7a6be2ebe1121cc09e4a204bf52c65a |
|
BLAKE2b-256 | 5a65289123887095687b21dd73ab66ea9919f6048d365fea1c814df80bdd94a8 |