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.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.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40eaec330011a43ef323578fa26b345508be06531e9b58f46f0e6247868bedc7 |
|
MD5 | 425f4560d2cb69118530d3dec4a869dc |
|
BLAKE2b-256 | 0a40816ad96e25c99c0745762b3200233b4014ccc4f3dd9274c41c006e466784 |
Hashes for python_rapidjson-0.9.0-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14a88283cfadfd5f7a26a60b7d47a99a9b80f7848a21d8c141497092535eec05 |
|
MD5 | ffb647d1879c8cfb7d6c1260497ca321 |
|
BLAKE2b-256 | 70ab7a746db666999f332b553ff544344fed34a4dc3514f3a81c2628d0b28df3 |
Hashes for python_rapidjson-0.9.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c1cdeddc383141e9440f8953559b16a9a753d687a77c33f4099369196dfeb3 |
|
MD5 | 3225c1ecaf1c8df1044865245a95c818 |
|
BLAKE2b-256 | 9d0cae35fcf92fb859ec02d38bf636bae55c72f43fab6e18c4bd5e2731c58ee4 |
Hashes for python_rapidjson-0.9.0-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cccbaec071bd8f80c8e40ed7468912a2e368f4399a3e2386b44f6a88992f7fd |
|
MD5 | efffdb7b35b7696c68af9c296f491ba2 |
|
BLAKE2b-256 | b6e9fd3639d4d2f16b80a76cd551194dd511942c5247f48276cfb0257d4220ad |
Hashes for python_rapidjson-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbbade7053ac3796d24ee1c0da20a201977d9e29266cbf590573cf0d48380b2c |
|
MD5 | 373f9936838555c7151e1a53e19c6cc6 |
|
BLAKE2b-256 | b88bdb2e536520fd954b55d198197929b2daa16e62fe0608af008e0c44db22f5 |
Hashes for python_rapidjson-0.9.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e86fceba0dc1825de0091ce5c0dd1b59580c4218a5215da2c8e201036ba294a1 |
|
MD5 | 1dcfe93bb6deb9d01ed04fe545a27c25 |
|
BLAKE2b-256 | d7e009b09ad8c51d3b88441c306e43b017b4c96f37914c6d5a29791b35212f8a |
Hashes for python_rapidjson-0.9.0-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67b0c1053c5bf60252b5cbfd750a020d05ba8323b2f2ce0dba0d5a9a5f624cd0 |
|
MD5 | f61c0bd41d191a24b351e1312bc4d794 |
|
BLAKE2b-256 | a38d44ba3d6e0029e332dbfc59e5a2cabf98e9d788698295af56b9398e37bb9d |
Hashes for python_rapidjson-0.9.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c927dae46d622ddd15a58b359d3ee98324099c38afbcb6eb89f8abe68531823e |
|
MD5 | 1e85f540e313ebaaf958f0dfcc7ddde4 |
|
BLAKE2b-256 | 57894dfc22eee5631c66327090994721b18f8a5e125cd3e006af1d0312bce3e6 |
Hashes for python_rapidjson-0.9.0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8822ed9998d061652c2786bc36576a71f44591e2e2d4ae1c6fe47c4dd92a8c77 |
|
MD5 | ae9775cdc44ce90d77ab3b6d1536c620 |
|
BLAKE2b-256 | f250c29e4d072d0aa13445d1f9d087565cd11d9757f48cad50cd0de9597bf3e9 |
Hashes for python_rapidjson-0.9.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37ff7eb5bc2e7b2194db8968baf167f221bae9f2adb25d34da191ef82ff6c5e9 |
|
MD5 | 0d0f47bcbc24dfe5bc3e20408e4ef9bc |
|
BLAKE2b-256 | 63e549726ceec9bccddb730f36cf1a6eec4b7df3d033f364a93a0f7f63f1c265 |
Hashes for python_rapidjson-0.9.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8ce5aac03d76616809e3e65baf05770fa2082fad4c8dd714d8625f783395234 |
|
MD5 | 4f2ba22b176bd8eb85269fdcf306291d |
|
BLAKE2b-256 | ad90cf75e5a677039c3932e6e3b1a336f6675d1fee04af5f080cad5e9c8552d0 |
Hashes for python_rapidjson-0.9.0-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f481b48752eae246de058462704dbeddd83342ded54f0db9ce06dd95891d289 |
|
MD5 | 452efeb4f740d91ada3792eb09c77c55 |
|
BLAKE2b-256 | d7d03ad822a0e5f47cc52dadc43d1a65c80dd2a2fd5e7c6080713bab4b120413 |
Hashes for python_rapidjson-0.9.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 621ee8c34f69aaca8637b89ae7be3bf93d6fe36eafb4be87abb4825b8ff3e16c |
|
MD5 | 9c671828c41dcfd2654ecffd2148481b |
|
BLAKE2b-256 | fd2031a106af5f70f0c71a44cd2194a792976c78251532781823a1342e28d26c |
Hashes for python_rapidjson-0.9.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2bfeea8423f24ff3bf54ff20c8d7d80ab7f3b1746e520174f68de6a91a9c1c6 |
|
MD5 | b669a584f45ecc6ff50c0d9345ac1f8f |
|
BLAKE2b-256 | 553cab59ef6a5b7ebcac481387b5cca22b2f85b2f1e0a6c1249516521bb55343 |
Hashes for python_rapidjson-0.9.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59a46e104791659081f69f3ecadb73ece0835b8d5f55d21c20aceea1dee4a16a |
|
MD5 | 85dc782b4fcb5830589f112869eea949 |
|
BLAKE2b-256 | 042cac57496bce829163b8d768c6de2398c8e2f8638e251761c39b15844aeb0b |
Hashes for python_rapidjson-0.9.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6b1ed871e69af957129df1f4f2fd6b0b76d40e672520d6f932f8f0ab0da93d3 |
|
MD5 | c3b00ea72f1b53e91cdd054c2f940f03 |
|
BLAKE2b-256 | eb1d628c5c63ca5467f14ed2b974b58c15f59748a52d965ff39f100fb31bd655 |
Hashes for python_rapidjson-0.9.0-cp35-cp35m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65e5f8f255b67479e41d5ff749465bdf91ac9f913244b54e60ec4e140ab71af2 |
|
MD5 | 79935b4960c3e129bc1502714a8cd136 |
|
BLAKE2b-256 | 277764b2ad70cca794208cef5683cfb0edd83b1c50f698c524b55258bcfcc799 |
Hashes for python_rapidjson-0.9.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aeff06e5711da09544110d54dde47234bf8d56c373c86b4b3bb5c10e4bba3bdc |
|
MD5 | e5fa4b8ac05c828897b517ea7e8d10e6 |
|
BLAKE2b-256 | 4dec18be3abe54c1ffeb3426ed8cdaec32e9b1c365fa63f34d345c258c9f9c95 |
Hashes for python_rapidjson-0.9.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a8e48dbc0bd21043930f08ce3c57f21a50b9222205a82a50bfbc392deec1808 |
|
MD5 | b7f69691b97a6cde7725eee77d855985 |
|
BLAKE2b-256 | 18681e4f61647964c191800b28fb8368a9cfd98fd44e279c4140273d445c720f |
Hashes for python_rapidjson-0.9.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a518143ddb9a3472eaae287072c43d33287c1c9ea1c8086c4fa80344ca68242 |
|
MD5 | 9799ff7737e6eaed49a67ef914ddd8cd |
|
BLAKE2b-256 | 199f161d406377e7ed567ad51bfbe49b2d8875935df00fe6bb0750d4d94b1db3 |