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.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.7.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16d7cbf00709a8d849359fa41c5cd462354af1dea10d9e1fe6e2865c36d533ec |
|
MD5 | e9f5e2ebf053312c77afd5a5397e29ee |
|
BLAKE2b-256 | fe5e1181db5c7c9ab577bbef254b4dc3204e1e7db57c007963b238624c75ab8b |
Hashes for python_rapidjson-0.7.2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14929156740a37bc3ec18aa6ac8b17013f4e9ecf2f2ac31267b8b4d601654ea4 |
|
MD5 | 2016dee142327a7bd1c7cb31395fc4e8 |
|
BLAKE2b-256 | eadbc65fc70a5098e19235b48a185107104b701f8058957757f93ca5ef951ffc |
Hashes for python_rapidjson-0.7.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0710751aaf31738c102f41af4330b62df8023914ce9481244a2b3cc964776ceb |
|
MD5 | 4b2739c925ebd9006260512996153151 |
|
BLAKE2b-256 | 2dbc1bd0f7e81ce80ce7cd606824435df97c7fbce740cde8fd6ebc8e428f006c |
Hashes for python_rapidjson-0.7.2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c62b96d22203f58183e3cebdbcab407babbad13ed6ccc8b3fd461d9c475157f |
|
MD5 | b8b49a2b248398709ec72c2a01cf1915 |
|
BLAKE2b-256 | d635a612f73a911bf2d9184d82ef91f2436bb4ad9b7aaa5c0b3f2387eade7fd4 |
Hashes for python_rapidjson-0.7.2-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a6e6e023a42b48f3a440723cca8cc16be3a5db9ea8f5c3e48aa63bc2d5fe79f |
|
MD5 | e75babc566337746502d9b879965552e |
|
BLAKE2b-256 | 1e190e82a860690710f0deed77036ac4876e887c42178f08c2606333f7d6ae91 |
Hashes for python_rapidjson-0.7.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd665648dc3b4416ceafb7dc155061b639a350c28650b3d028f769a91184ce69 |
|
MD5 | 4237f8131e17698b9e03b433b3a2bbb0 |
|
BLAKE2b-256 | c7cf5549a3951adb108592c2688925a3fb6134dd1c6e814ccb260579587b57e0 |
Hashes for python_rapidjson-0.7.2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d38228984ced0a95da469e5f77c5affb67fc6c6dd2214fd738af63d386fc48a |
|
MD5 | b925ca059d3214aff970982c21a2c1da |
|
BLAKE2b-256 | bceeaa6b6bf6bf778b908c99fa59dc4f70a3d3e1475c4bd703589b67e3fd5eb8 |
Hashes for python_rapidjson-0.7.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93804ffffda7bb7db43cd3d736623805adf147372eed4d10ce9464663881acf3 |
|
MD5 | edefb4f6ea34f4e47618596462c12ff6 |
|
BLAKE2b-256 | 12ed0c25fabe7963fa259d73cad79d958749a86a0ae964f9a842e26c54418f03 |
Hashes for python_rapidjson-0.7.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d32c2b0f5fc2b29f8317ec77ae141655814fe151ef530adb007b33f8b48abdf |
|
MD5 | 81884bb494f62736177357e030e09a46 |
|
BLAKE2b-256 | 0721a71576eb9b96cc7b8ad9d2ce91ace36a69b218f3a02a6287f0f0256b9b21 |
Hashes for python_rapidjson-0.7.2-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaf930000666aabdb62253201f291406e1dc407655788d8074c91ba361fb1909 |
|
MD5 | afb9480e411918b50cb86d36f2524dd0 |
|
BLAKE2b-256 | da3cec60b2d02ca81a2430431f94074d8e3f92ebdecd89172e8c745cfdd138ed |
Hashes for python_rapidjson-0.7.2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af97a0c37747bf9b9e0176394ebbfe2bb8543eecff91d38824dafbd27fef4a20 |
|
MD5 | d105f73d09ca30616a5e769b59529b2a |
|
BLAKE2b-256 | ab95f363c631321e2f88bb3b9847b253fc168b431f6409eccbabb72d1a5b1721 |
Hashes for python_rapidjson-0.7.2-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c639e8f064a1bfa8285fec1cd72361a5ccd8adc64497ab9f9e3799edbbc5694 |
|
MD5 | 1d49f76d0089161df8b576c1340240ed |
|
BLAKE2b-256 | 884530e004bbf8375d7e833cddcbbea20d2b66c034bb41e6b042867b81ffd9a2 |
Hashes for python_rapidjson-0.7.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c745bbac3047d9d2dd6dc55d7fdfc34bb08f40a1873ac8c8e2a5bf9a144fb1e5 |
|
MD5 | cc5bdebbe471ff59008961cdc805b9a6 |
|
BLAKE2b-256 | 680632c9545484342ca9a9935e500233f6c4cf4713df06b8379d33384f60313c |
Hashes for python_rapidjson-0.7.2-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a09c0bb905fdc30527c0147ba530b26f3091ecdba19eb1aa4a6c0fcfa4230ee |
|
MD5 | 2f09d10231a030bcb8c27bbb996f2d2c |
|
BLAKE2b-256 | 1c6ed4af158d7db77d82d5c5bddcce6d32103ad48a94988e2a76fa83b2e62209 |
Hashes for python_rapidjson-0.7.2-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 795e3a0fdaccbf229b7b2b78f2f2b83a6884a6f3690ae49e64e90465401b1a9b |
|
MD5 | 624030bdce43924b5fe94240dad066f0 |
|
BLAKE2b-256 | 97e819fef8da0d5c208946338ac74bddfae0184bd5b83abb0cd5ab0f9710052f |
Hashes for python_rapidjson-0.7.2-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 467ca7ee00f20683161c868ce16a3deb68b233a4a4fcc072b41f1cb7c89171f4 |
|
MD5 | a2a1ecba7dda2533446a666f020dcea3 |
|
BLAKE2b-256 | 23f759e14c55f303ea9008822b4e8e9cea8c89e8a63471062d720db1299339cd |
Hashes for python_rapidjson-0.7.2-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 090a0c8604759a47db56fad0a7817eaa072bb7eb3aa76f71a4fa6c58c1302b74 |
|
MD5 | d6e777e55e2b8eee20c503f384a67d7a |
|
BLAKE2b-256 | 75a622900da634f77c1cc1b0b4ec73305c0a607dadbf3b6ed20e5fe4a8240e5f |
Hashes for python_rapidjson-0.7.2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3656dba8038ec08fa6aec1ccb9b8b04e4f3d747c41ae2a63a3b40076653d7439 |
|
MD5 | 603f71f7b13296f1133c03c4ab139ec7 |
|
BLAKE2b-256 | d4ac1df4b537ab68fca1fb195c8496495549b6ed2486cfc9f3bd67c3c8244a76 |
Hashes for python_rapidjson-0.7.2-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94a25d52c434439afb6a64930a4dd3ea85fbcbb164a7bddea3ade3552c7e877e |
|
MD5 | b205a2d78df2dd754512cf3762daaed1 |
|
BLAKE2b-256 | fd49a8d24d93a9e52afef0997310cbd3798436aad933e7f8ea230751dea9da31 |
Hashes for python_rapidjson-0.7.2-cp34-cp34m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e15b1fda6f8b4dc15528c473d1bdb178b942c260a7822f112292059228cf057 |
|
MD5 | 038d1ffedb46dad0d3211ad6cae6d04b |
|
BLAKE2b-256 | 784cf3e60acca9110c04db408798846f7243818fc53a793c12e26e9b78c78cd2 |