orjson — A fast json parser for python
“orjson is a fast, correct JSON library for Python. It benchmarks as the fastest Python library for JSON and is more correct than the standard json library or other third-party libraries. It serializes dataclass, datetime, numpy, and UUID instances natively.”
~orjson github readme
When to Use?
orjson
and other alternative json parsers to the builtin json
package in python’s standard library provide extra tooling for object serialization as well as significantly increased read\write speed making this an ideal tool where workload demands are higher.
Example
simple and familiar to json
Benchmarks
Its fast… like really fast.
https://github.com/ijl/orjson#performance
Some Numbers
- serializes
dataclass
instances 40-50x as fast as other libraries - serializes
datetime
,date
, andtime
instances to RFC 3339 format, e.g., "1970-01-01T00:00:00+00:00" - serializes
numpy.ndarray
instances 4-12x as fast with 0.3x the memory usage of other libraries