All Projects → mre → Hyperjson

mre / Hyperjson

Licence: other
A hyper-fast Python module for reading/writing JSON data using Rust's serde-json.

Programming Languages

python
139335 projects - #7 most used programming language
rust
11053 projects

Projects that are alternatives of or similar to Hyperjson

Json C
https://github.com/json-c/json-c is the official code repository for json-c. See the wiki for release tarballs for download. API docs at http://json-c.github.io/json-c/
Stars: ✭ 2,313 (+518.45%)
Mutual labels:  hacktoberfest, json
Json 2 Csv
Convert JSON to CSV *or* CSV to JSON!
Stars: ✭ 210 (-43.85%)
Mutual labels:  hacktoberfest, json
Circe
Yet another JSON library for Scala
Stars: ✭ 2,223 (+494.39%)
Mutual labels:  hacktoberfest, json
Browser Extension Json Discovery
Browser (Chrome, Firefox) extension for JSON discovery
Stars: ✭ 157 (-58.02%)
Mutual labels:  hacktoberfest, json
Jackson Databind
General data-binding package for Jackson (2.x): works on streaming API (core) implementation(s)
Stars: ✭ 2,959 (+691.18%)
Mutual labels:  hacktoberfest, json
Jackson Core
Core part of Jackson that defines Streaming API as well as basic shared abstractions
Stars: ✭ 2,003 (+435.56%)
Mutual labels:  hacktoberfest, json
Nanoutils
🌊 Tiniest FP-friendly JavaScript utils library
Stars: ✭ 200 (-46.52%)
Mutual labels:  hacktoberfest, module
Fossurl
Your Own Url Shortner Without any fancy server side processing and support for custom url , which can even be hosted on GitHub Pages
Stars: ✭ 131 (-64.97%)
Mutual labels:  hacktoberfest, json
mediawiki-antispam
Antispam extension for MediaWiki.
Stars: ✭ 15 (-95.99%)
Mutual labels:  extension, module
wulaphp
一个有点复杂的PHP框架!
Stars: ✭ 26 (-93.05%)
Mutual labels:  extension, module
Configurate
A simple configuration library for Java applications providing a node structure, a variety of formats, and tools for transformation
Stars: ✭ 148 (-60.43%)
Mutual labels:  hacktoberfest, json
Lsp Mode
Emacs client/library for the Language Server Protocol
Stars: ✭ 3,691 (+886.9%)
Mutual labels:  hacktoberfest, json
Smoke
💨 Simple yet powerful file-based mock server with recording abilities
Stars: ✭ 142 (-62.03%)
Mutual labels:  hacktoberfest, json
Json Api
Implementation of JSON API in PHP 7
Stars: ✭ 171 (-54.28%)
Mutual labels:  hacktoberfest, json
Packages
📦 Package configurations - The #1 free and open source CDN built to make life easier for developers.
Stars: ✭ 139 (-62.83%)
Mutual labels:  hacktoberfest, json
Mtgjson
MTGJSON build scripts for Magic: the Gathering
Stars: ✭ 191 (-48.93%)
Mutual labels:  hacktoberfest, json
Cphalcon
High performance, full-stack PHP framework delivered as a C extension.
Stars: ✭ 10,534 (+2716.58%)
Mutual labels:  hacktoberfest, extension
Skip Silence
🔇 Chrome extension to skip silent parts in videos and audio files on any webpage
Stars: ✭ 130 (-65.24%)
Mutual labels:  hacktoberfest, extension
Horaires Ratp Api
Webservice pour les horaires et trafic RATP en temps réel
Stars: ✭ 232 (-37.97%)
Mutual labels:  hacktoberfest, json
Faceaware
An extension that gives UIImageView the ability to focus on faces within an image.
Stars: ✭ 3,004 (+703.21%)
Mutual labels:  hacktoberfest, extension

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. 😉

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:

  • [x] Implement loads()
  • [x] Implement load()
  • [x] Implement dumps()
  • [x] Implement dump()
  • [x] Benchmark against json and ujson (see #1)
  • [x] Add a CI/CD pipeline for easier testing (see #2)
  • [x] Create a proper pip package from it, to make installing easier (see #3).
  • [ ] Profile and optimize performance (see #16)
  • [ ] Add remaining keyword-only arguments to methods

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

Developer guide

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

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
export PATH="$HOME/.poetry/bin:$PATH"

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].