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.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.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c7d089975cc2fb0f4aec55347d53183b64437271e2bd7a7e61e3b30cc27d76d |
|
MD5 | 8b3709c4e3172bcdbe21674f36fdf78b |
|
BLAKE2b-256 | cf16f7368fd875ed84efb13ddbcf1bccbe4666b89fa3fdceeaa498ceb26e649c |
Hashes for python_rapidjson-0.9.3-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37a2cb20920951460a5f5f4de445c25a42c332c09adfe201236a7cc2c8509d17 |
|
MD5 | 8d6e95fc3b31e0db03054e9424886042 |
|
BLAKE2b-256 | 1edec7748f1a0d3e4b3122e2f021a2a555f566f4daf1762d3705e1878b3a0bad |
Hashes for python_rapidjson-0.9.3-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89379057664d92b4286ac547f8b6785a0bf71799bcd451caa590b383b9c2f0f7 |
|
MD5 | baae7b1e3debd478b71c2f237c0549f9 |
|
BLAKE2b-256 | dc71d86ebb0fa9b0233574b7e51c8cbab9e4b2b1bc1304df99449c5850fab861 |
Hashes for python_rapidjson-0.9.3-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf4c1b85b803a99021b9adeca98265cf1eb70e73ca398954f61a4e8dfb5e06e0 |
|
MD5 | 01ac05f990d3d646edd5935b3cfb9824 |
|
BLAKE2b-256 | 58b5ed830f98fae0bac84aba0c15e93d538d86b580aa1440c4f016f0360237ad |
Hashes for python_rapidjson-0.9.3-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4a722d8c7809e326251d5fd5b0ed679ec81df27a7682eace62a02232afcc72d |
|
MD5 | 8b015169eaa6b3c8fc30fb3c0aa27018 |
|
BLAKE2b-256 | ca851cc54278df866d47f68ecd76c78aaa66c4a41c9df7265831e1ca7a44c4a5 |
Hashes for python_rapidjson-0.9.3-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | baaea8193ddcc1b147b861086caaa737fb3f8fe259fa8e32a182e19c3264dfd8 |
|
MD5 | 152d79f9ec2d3a69423e034315ea30dd |
|
BLAKE2b-256 | 083d2697f7298cfa5685866c4f9067d9824f8d8f2e17c72890439fe774e8a99a |
Hashes for python_rapidjson-0.9.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0c419c269719e536ae9f23edef6105914905b4c6a0b42399a4f20994a94df51 |
|
MD5 | 2517aab7d7726174382b71d293b739bf |
|
BLAKE2b-256 | dcd1997d1fa7eeeefef7504cba1f7533fd306c9adfd85053829b5092268c1cfb |
Hashes for python_rapidjson-0.9.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d523076d07974c78c9c5a75cd2ad29e8230d784bb6993cfd124597de51c0ff10 |
|
MD5 | 3a5ca9701e988a4ed5e45ccfe6318298 |
|
BLAKE2b-256 | 02ccb83e30ae6a5dde9c961b377c06eee094aac57bfcc780d05258ab04896c15 |
Hashes for python_rapidjson-0.9.3-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e112b38067a7d95c398ab9d8baeccade8b206ef6d08afdcdaed23a6db07ff3b0 |
|
MD5 | a8efa429628396c827434d3713df7474 |
|
BLAKE2b-256 | c11aecf59741c5f3aa1e051d42226fa8f6f06d9f46e0d65436a9000ab16b4d7d |
Hashes for python_rapidjson-0.9.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ec6f2b876e4f14b0fa1f31da84bf158945d72279470791efde7381701264e98 |
|
MD5 | ce5826a72c4af125bac38a0cc47fc883 |
|
BLAKE2b-256 | 6ec8d48a8ad865685cf5f8453430c76ffb3a6b07ddf3f3440034195a0367e869 |
Hashes for python_rapidjson-0.9.3-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e5f022f13a2c58267f2827309af36495f9fa0844c1d5e983b74022afe9c91cc |
|
MD5 | 86cdc9e0a84e248895b6633341192dd3 |
|
BLAKE2b-256 | a5570d9d8a64c9878ff66e0566a91e53795774adcab483088947e13d9c24cb03 |
Hashes for python_rapidjson-0.9.3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ff5005ff05f942d232e2aae0676db235c572363eda8018f6680a3d2fd6b15da |
|
MD5 | 4fc5b8bbc4cc5e0b51859598e851ee1b |
|
BLAKE2b-256 | 7b206c414857d99efc38368b9f8b2a278c81b46545e3dc8707f9602804161dde |
Hashes for python_rapidjson-0.9.3-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89edf6193f20fc014acbc80174e8c505bfdd4daf7a2ba9420690b7abdb22edd3 |
|
MD5 | 97bff5b11340551314a4e004769ab953 |
|
BLAKE2b-256 | 17374d82afbeaee83307cff4c1906473638fcb1757aab43e83112f05f38b0675 |
Hashes for python_rapidjson-0.9.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ba9b3f6fb67c1dc5dcb3f0ae41c059076f613bd0ff28f86b4fe9abb57525cf8 |
|
MD5 | 5fa6c02a414c81d90442476c732d2d6e |
|
BLAKE2b-256 | c24446888d97bed696eaa395e605f385dff6c6627505e63c7c950f69f32543b6 |
Hashes for python_rapidjson-0.9.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 202fe95fec7bc8b86206b5c752ed954892951d0aee4b79ae1a3f5d311f762449 |
|
MD5 | d92baa1111888b10a7bc0e4391bfc1e4 |
|
BLAKE2b-256 | f39cd039e26470b7443f11e2fc1e1ea5cd48c222384a9c387e95b5bbaed7cb9f |
Hashes for python_rapidjson-0.9.3-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8a49f1310e9e6904f716d20ce50b08a026908b5dc3d4eae3a7f4ecaf09403b2 |
|
MD5 | d4dc2d39a990493941af7f86282239ca |
|
BLAKE2b-256 | 68df88f85f3ffa1b949bc6e465aa828fe02fc2fee55021a9b4bd683202992996 |
Hashes for python_rapidjson-0.9.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59771858dfa191cde894c233fc38a640df7131cb88598d21b0154515ba9b6285 |
|
MD5 | 040c3ee169bf43a453cb2df65c5f6fcc |
|
BLAKE2b-256 | 67a88decef6477075b5f14f789a06781daac3bd0bb72573c21f9f86b6aa5eed0 |
Hashes for python_rapidjson-0.9.3-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f590bffea361362f7bf68da438e8725833f21b29285a81baa7438a3aceda1a2 |
|
MD5 | bf445dc9bc54bbed8d326838f2ef4d56 |
|
BLAKE2b-256 | 18b551488bad869afae87708e2769f85d7b8d1942409741ba3af2928439f8d51 |
Hashes for python_rapidjson-0.9.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3d0835cd04f86044bfa4ac5b35398f69b8c1ba85e08c34893c88b00514dbe83 |
|
MD5 | 23f7b9838e0b6dd350c9c1a4c19ab791 |
|
BLAKE2b-256 | b85746dcd96b08ffb645f58e0cff4ed1097535715dce973388ef259715383516 |
Hashes for python_rapidjson-0.9.3-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62c467d8c54b0360891f0cab4b60996e34a410fc5e58f69268750c5a432a6b92 |
|
MD5 | b2bc8b6272a4b9b8490858b1d472bb99 |
|
BLAKE2b-256 | 8a8f4b3396208da140099859a486b2485f96a3094bab036e7f62328b6797fc0b |
Hashes for python_rapidjson-0.9.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcd833fb65240a8b3b31475f886729a45621a44ea06870b4114b5471cfd3f08c |
|
MD5 | 99b65a13bf25b06a394fece02c69ee8e |
|
BLAKE2b-256 | 87a5abd4123da8e3da3ff083e98c8a71d0cc4ad22e16c360ef0f72f5da870920 |
Hashes for python_rapidjson-0.9.3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af8dbe6a7ba24b29c2376becc57400125c5e5bc71a97f68425b02afbe6ed9b84 |
|
MD5 | 2f3c2951c4bd0f88ba0a1eec9da67f70 |
|
BLAKE2b-256 | 9f8755c9b3d1bdf098e22de7e9d4f7f4a00d24e78e0d027540992b1b95e41188 |
Hashes for python_rapidjson-0.9.3-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e24d271fa2d2791d16354a7101466050a21f476b5a45ba620772b4c727c4510 |
|
MD5 | 815a252d21386337a77ffdd5ec41b067 |
|
BLAKE2b-256 | c10bf6cdd14de321956b6558f90000522e58fc715f98321ec5365a9c4ac6dca3 |
Hashes for python_rapidjson-0.9.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1971d4e49166624bb778ce1d023805c1635a87a139dfc39748024c73dd1291dc |
|
MD5 | 106c52f2c3a911caf6fcaf8fd148ab7f |
|
BLAKE2b-256 | f2b210299f81479fb2869065ca81f65a4e1c3e16e0e78a9033713bdb6b138625 |
Hashes for python_rapidjson-0.9.3-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d09cf5359738e591f6638e81db2cc0de499e0dbd2d7b495ba968b2a175f2d9c5 |
|
MD5 | 7a7f1846ba3dec5a23ca3decdd116934 |
|
BLAKE2b-256 | f780d663f59e5d925e6fbd01ef4199414aef6856d33978c7676cd9553952bff0 |
Hashes for python_rapidjson-0.9.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72aa3daa4c1b0df16e262e7cbec5c05eb42c785897c9a3ca4293c3a7d36a6081 |
|
MD5 | 8b8e49c60a6cd40efc46b9aa61201319 |
|
BLAKE2b-256 | c9e00cf098e3cbc4c83604db857135906818899c4ec449d3349b44e7d8cc6726 |
Hashes for python_rapidjson-0.9.3-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cfe81cbece443e5922f6570f40c1af8f9f58e80e3606e6dd6f94d34aa18d5b6 |
|
MD5 | 2cd06b7b428b615dd413a3ff434b5191 |
|
BLAKE2b-256 | 77187f3266a9759ccb61cba6e6901f68bb7cdd68e363e2e38587ce2c5a47ff51 |
Hashes for python_rapidjson-0.9.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e5e3a5acb2511d40f3b67191f96a2f5cc0d888bd5f392fd770059e2cdbff8ed |
|
MD5 | 22e58883d6b20868942b2c271579eacb |
|
BLAKE2b-256 | da663f809b52b5dd2dad116dfb5c7c3f04f165ca767262f726c11342b254c7f8 |