Skip to main content

hyperjson

Build Status

A hyper-fast, safe Python module to read and write JSON data. Works as a drop-in replacement for Python's built-in json module. This is alpha software and there will be bugs, so maybe don't deploy to production just yet. :wink:

Installation

pip install hyperjson

Usage

hyperjson is meant as a drop-in replacement for Python's json module:

>>> import hyperjson
>>> hyperjson.dumps([{"key": "value"}, 81, True])
'[{"key":"value"},81,true]'
>>> hyperjson.loads("""[{"key": "value"}, 81, true]""")
[{u'key': u'value'}, 81, True]

Motivation

Parsing JSON is a solved problem; so, no need to reinvent the wheel, right?
Well, unless you care about performance and safety.

Turns out, parsing JSON correctly is a hard problem. Thanks to Rust however, we can minimize the risk of running into stack overflows or segmentation faults however.

hyperjson is a thin wrapper around Rust's serde-json and pyo3. It is compatible with Python 3 (and 2 on a best-effort basis).

For a more in-depth discussion, watch the talk about this project recorded at the Rust Cologne Meetup in August 2018.

Goals

  • Compatibility: Support the full feature-set of Python's json module.
  • Safety: No segfaults, panics, or overflows.
  • Performance: Significantly faster than json and as fast as ujson (both written in C).

Non-goals

  • Support ujson and simplejson extensions:
    Custom extensions like encode(), __json__(), or toDict() are not supported. The reason is, that they go against PEP8 (e.g. dunder methods are restricted to the standard library, camelCase is not Pythonic) and are not available in Python's json module.
  • Whitespace preservation: Whitespace in JSON strings is not preserved. Mainly because JSON is a whitespace-agnostic format and serde-json strips them out by default. In practice this should not be a problem, since your application must not depend on whitespace padding, but it's something to be aware of.

Benchmark

We are not fast yet. That said, we haven't done any big optimizations. In the long-term we might explore features of newer CPUs like multi-core and SIMD. That's one area other (C-based) JSON extensions haven't touched yet, because it might make code harder to debug and prone to race-conditions. In Rust, this is feasible due to crates like faster or rayon.

So there's a chance that the following measurements might improve soon.
If you want to help, check the instructions in the Development Environment section below.

Test machine:
MacBook Pro 15 inch, Mid 2015 (2,2 GHz Intel Core i7, 16 GB RAM) Darwin 17.6.18

Serialization benchmarks Deserialization benchmarks

Contributions welcome!

If you would like to hack on hyperjson, here's what needs to be done:

Just pick one of the open tickets. We can provide mentorship if you like. :smiley:

Developer guide

This project uses pipenv for managing the development environment. If you don't have it installed, run

pip install poetry

The project requires the nightly version of Rust.

Install it via rustup:

rustup install nightly

If you have already installed the nightly version, make sure it is up-to-date:

rustup update nightly

After that, you can compile the current version of hyperjson and execute all tests and benchmarks with the following commands:

make install
make test
make bench

🤫 Pssst!... run make help to learn more.

Drawing pretty diagrams

In order to recreate the benchmark histograms, you first need a few additional prerequisites:

On macOS, please also add the following to your ~/.matplotlib/matplotlibrc (reference):

backend: TkAgg

After that, run the following:

make plot

License

hyperjson is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in hyperjson by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Metadata

Release files for hyperjson 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for hyperjson 0.2.4
File
hyperjson-0.2.4-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
hyperjson-0.2.4-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
hyperjson-0.2.4-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
hyperjson-0.2.4-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details
hyperjson-0.2.4-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
hyperjson-0.2.4-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details
hyperjson-0.2.4-cp36-none-win_amd64.whl CPython 3.6 none Windows x86-64 Details
hyperjson-0.2.4-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
hyperjson-0.2.4-cp36-cp36m-macosx_10_7_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64 Details
hyperjson-0.2.4-cp35-none-win_amd64.whl CPython 3.5 none Windows x86-64 Details
hyperjson-0.2.4-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
hyperjson-0.2.4-cp35-cp35m-macosx_10_7_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.7+ x86-64 Details

Total release size: 2.1 MB

Release files / hyperjson-0.2.4-cp38-none-win_amd64.whl

Download URL hyperjson-0.2.4-cp38-none-win_amd64.whl
Size 164.2 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
cf70d244f0bce0db4a6d0cb2958dcf14283045f17098831f5e8ef34b3d4a67a8
BLAKE2b-256 checksum
How to use checksums
d1ee32eff3ee2754b1713409478052b01bfac7020cff45fa56417fa6451c0d56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp38-cp38-manylinux1_x86_64.whl

Download URL hyperjson-0.2.4-cp38-cp38-manylinux1_x86_64.whl
Size 191.1 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
4451c5b85471a14d5d8ee1764e2622301979bf41da9be95472fb279f0c5db4b6
BLAKE2b-256 checksum
How to use checksums
14dc746513b710a32f7e3529ad26d4d0133107f3bed9096c0a3d96920775868a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp38-cp38-macosx_10_7_x86_64.whl

Download URL hyperjson-0.2.4-cp38-cp38-macosx_10_7_x86_64.whl
Size 167.6 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
59ebe0e4b8f1a97c078cc5a7d214c59eda24acc1e530ae9f26a4148e26cca9e6
BLAKE2b-256 checksum
How to use checksums
fb82718296dd66b194984e5e182d5646e096d0c4cc41ec13db2f7053ca7f8715
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp37-none-win_amd64.whl

Download URL hyperjson-0.2.4-cp37-none-win_amd64.whl
Size 164.2 kB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
e4ab23d72c3646a3053db049a14b1fdf79521e04d2db98b18dc0dc858de242e2
BLAKE2b-256 checksum
How to use checksums
a64f1392ef06faec75b80726816d9ca52d5ef0163f4f495f32201ba489ce38aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp37-cp37m-manylinux1_x86_64.whl

Download URL hyperjson-0.2.4-cp37-cp37m-manylinux1_x86_64.whl
Size 191.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
a9b6f33593729c1ba5990c46f8d34e61d63670d15622c228663fe3528e4149ad
BLAKE2b-256 checksum
How to use checksums
ad51008a732d3e92d44e9b358ab668df6a95303088f9374ae72a73f158f842ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL hyperjson-0.2.4-cp37-cp37m-macosx_10_7_x86_64.whl
Size 167.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
31b7287c8973ec92a14ced88f29b075568d884ec63a03a3bd18046ff445e085f
BLAKE2b-256 checksum
How to use checksums
e3ce23dc13114354b496ed6680599a169790af2717281d9c2bb9204683944bb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp36-none-win_amd64.whl

Download URL hyperjson-0.2.4-cp36-none-win_amd64.whl
Size 164.4 kB
Tags CPython 3.6 Windows x86-64
SHA-256 checksum
How to use checksums
fc70be6d7e0f4cef9e79e965400b8e6167caaa14305016e1226e92b3a6ec52ec
BLAKE2b-256 checksum
How to use checksums
c709b9dc6e67228236100df442e92ea38e2d28f7fe76c553aa9b492381540231
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp36-cp36m-manylinux1_x86_64.whl

Download URL hyperjson-0.2.4-cp36-cp36m-manylinux1_x86_64.whl
Size 191.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
3342dd9296035d8f0670f09e246ab36fea1017c4dae73c24a418960ed1eb8beb
BLAKE2b-256 checksum
How to use checksums
4625cc2b3f1dfd4c7b2e559e671472775a126a8a5044d49dc942bfde5c6e34eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp36-cp36m-macosx_10_7_x86_64.whl

Download URL hyperjson-0.2.4-cp36-cp36m-macosx_10_7_x86_64.whl
Size 167.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
005dee52ee0646ecc2173199223e73a5a7a85cbfb9b888b0f4bc9e07906dd0ca
BLAKE2b-256 checksum
How to use checksums
823ac4b490b9e68fb899fca4e4071cfab5f7486b4056e298f630db7ec25905de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp35-none-win_amd64.whl

Download URL hyperjson-0.2.4-cp35-none-win_amd64.whl
Size 164.4 kB
Tags CPython 3.5 Windows x86-64
SHA-256 checksum
How to use checksums
6dff1448fd69378703f50cfdacc8e5de36a9b0da3d8c4016add80dc9b6f8cc3b
BLAKE2b-256 checksum
How to use checksums
e737e3cf269bd0fe3a19978f826cb68e131bf6918592a044019a0a264c08caa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp35-cp35m-manylinux1_x86_64.whl

Download URL hyperjson-0.2.4-cp35-cp35m-manylinux1_x86_64.whl
Size 191.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
95a411e6460307fd51f51e387522ff1e0387a9dae7d1a4b5cdaa07fce7cd5e6f
BLAKE2b-256 checksum
How to use checksums
91ceca2f48d4c31d31386719f30ea536d3a4308453e8dcb49079e87423b4a6a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release files / hyperjson-0.2.4-cp35-cp35m-macosx_10_7_x86_64.whl

Download URL hyperjson-0.2.4-cp35-cp35m-macosx_10_7_x86_64.whl
Size 167.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
c222f8f613ad729336e1f01108f242cbd1cf8ef361a3cd2b69a21a470b5adff1
BLAKE2b-256 checksum
How to use checksums
a4346d19f99d9871fcc5fd01b97a7ddb33cbf7a20b98929d3d23f64286e6b8e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.7.7

Release history Release notifications | RSS feed

This release

0.2.4 This release

12 release files

0.2.1

1 release file

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page