Skip to content

Benchmarking🔗

Compare the default JsonFormatter, OrjsonFormatter, and MsgspecFormatter with the opt-in benchmark suite. Measurements cover serialization and complete record formatting. They help you choose a backend for a workload; they do not predict application throughput or handler I/O performance.

Complete-formatting summary🔗

These graphs summarize complete record formatting from the baseline results. Bars show the arithmetic mean of the per-version median operation times. Whiskers show the minimum–maximum of those version medians, not individual timing samples.

Speedups average each version's ratio against CPython stdlib JSON for the same workload and Python major/minor version. Only versions with a matching reference contribute. Lower times and higher speedups indicate faster formatting. Each panel starts at zero and has its own scale.

Complete-formatting times and speedups by workload, with mean and version ranges

Run benchmarks🔗

From a repository checkout, install the benchmark dependencies:

uv sync --python 3.15 --no-default-groups --group benchmark

On CPython, this group installs all three backends. On PyPy, it installs only the stdlib backend and benchmark tools. Cases for unavailable optional encoders are reported as skipped. The published comparison covers standard GIL-enabled CPython 3.10–3.15 and PyPy 3.10–3.12. Each published CPython result must contain all three backends; PyPy results contain stdlib JSON only.

Check every case without collecting performance measurements:

uv run --no-sync pytest benchmarks --benchmark-disable

Collect measurements with warmup and export the results:

mkdir -p benchmark-results
uv run --no-sync pytest benchmarks --benchmark-warmup=on \
  --benchmark-json=benchmark-results/python-3.15.json

You can also use tox with its uv runner:

uvx --with tox-uv tox -e py315-benchmark
uvx --with tox-uv tox -e pypy312-benchmark

Append -benchmark to a supported tox runtime name to benchmark that interpreter. The workflow selects tox's benchmark label with tox -m benchmark. Ordinary test and benchmark environments share version lists in tox.ini, so supported versions are maintained in one place. Use uvx --with tox-uv tox -e benchmark to use the default interpreter. Results go to the environment's envtmpdir, such as .tox/py315-benchmark/tmp/benchmark.json. Pass pytest options after -- to select cases or change measurement settings. For example, use -k unicode to select Unicode workloads. Normal test runs collect only tests/ and do not need the benchmark dependencies.

The manual Benchmark JSON formatters GitHub Actions workflow runs Linux x86-64 benchmarks for the supported CPython and PyPy versions. One tox invocation runs the runtimes sequentially in one job on the same runner. The job uploads a single artifact containing one JSON file per runtime, and its summary contains the comparison tables. Timing differences never fail CI.

Measurement methodology🔗

The suite uses pytest-benchmark for pytest integration, automatic calibration, statistics, and JSON export. Run on an otherwise idle machine, use warmup, and repeat runs before interpreting small differences. Benchmarks and Python environments run sequentially; do not run multiple benchmark sessions concurrently on the same machine.

Each backend uses its default formatter configuration. The two measurement layers are:

  • Serialization: jsonify_log_record() on a prepared dictionary, including bytes-to-string conversion in the orjson and msgspec formatters.
  • Formatting: format(LogRecord) on a prepared record, including field extraction, message handling, exception formatting where applicable, and serialization.

Formatter and record construction, payload preparation, correctness checks, and handler I/O are outside the timed operation. Formatters and records are reused. Checks before and after measurement verify expected parsed content and consistent repeated output. Exception records retain exc_info, so formatting includes rendering the traceback on each call; serialization uses prepared exception text.

Workload Payload
simple A short string message
structured A string message with scalar LogRecord extras
nested A dictionary message containing 100 objects with lists and nested metrics
unicode A repeated message containing accented text, Japanese text, and emoji
rich A dictionary message containing a UTC datetime, UUID, dataclass, bytes, an Enum class, and its members
exception A message and a prepared ValueError traceback

Default outputs can differ. Stdlib JSON escapes non-ASCII characters and uses spaces between elements; the other backends emit compact UTF-8. UTC datetime strings use +00:00 for stdlib and orjson, and Z for msgspec. These are comparisons of the supported formatter defaults, including native rich-type support and fallback encoding costs. They are not byte-identical raw encoder comparisons. Bytes are encoded as base64 strings; the Enum class is encoded as a list of member values, and each Enum member is encoded as its value. JSON results record each case's output size.

Repetitions, variation, and precision🔗

Warmup and calibration run before timing. pytest-benchmark chooses a batch of iterations per round and repeats those rounds. Statistics describe the per-operation average duration of each round, rather than individual logging call latencies. See the pytest-benchmark glossary.

The generated summary and timing tables record the actual round counts and iterations per round. Calibration and warmup calls are additional and are excluded from those counts. Each runtime has one full suite run; thousands of timing rounds are not thousands of independent suite runs or machines.

Timing tables show median, arithmetic mean, standard deviation (SD), and interquartile range (IQR), all in microseconds per operation. IQR is Q3 minus Q1: the width containing the middle 50% of round averages. Median and IQR are less sensitive to slow outliers than mean and SD. The JSON also retains minimum, maximum, quartiles, and outlier counts.

There is no universally trustworthy number of decimal places in microseconds. The generated summary reports the observed SD relative to the mean, including outliers. Reported times use at most three significant digits; spreads and speedups use at most two. This is display rounding, not a claim of accuracy. Batching reduces timer overhead, but cannot eliminate scheduler, garbage collection, CPU frequency, or hosted-runner variation. Do not interpret the final displayed digit as a reliable performance difference. Check IQR and SD, and repeat complete runs on the same machine before drawing conclusions about small differences.

Timing plots use labeled horizontal bars, with one panel per workload and measurement layer. Speedup plots use two panels (serialization and complete formatting), with bars grouped by workload and guides at shared group boundaries. All axes are linear and start at zero; ranges differ between panels. Compare bar lengths within a panel; use the numeric labels and tables to compare workloads. Timing bars show medians without whiskers. IQR and SD remain in the tables to show within-run variation; they do not measure between-run reproducibility. Separate speedup tables and plots divide the stdlib median by each backend's median for the same workload, layer, and Python major/minor version. The reference is CPython stdlib JSON; a standalone PyPy report uses PyPy stdlib JSON. Values above 1 mean that the backend was faster in that measurement. Speedups are descriptive ratios without inferred confidence intervals. Only stdlib JSON is measured on PyPy. All runtimes in one workflow invocation share the same runner. Runtime versions and dependencies still differ, and separate invocations can use different hardware. Comparisons do not isolate interpreter performance. Exact patch versions and environments are recorded separately.

Update results🔗

The curated baseline consists of one JSON file per Python implementation and version under benchmarks/results/, collected from one workflow invocation. Later workflow runs remain artifacts until explicitly selected as a replacement. Download and extract the benchmark-results artifact from the chosen invocation into benchmark-results/downloaded/. Keep each JSON file under its original name. Curate the files and regenerate the tables:

python scripts/benchmark_report.py benchmark-results/downloaded/*.json \
  --curate benchmarks/results
python scripts/benchmark_report.py benchmarks/results/*.json \
  --update docs/benchmarking.md --plots assets/benchmarking
uv run --no-default-groups --group benchmark-report \
  python scripts/benchmark_plots.py benchmarks/results/*.json \
  --output docs/assets/benchmarking

Curation removes individual timing sample arrays to keep repository files small. It preserves every summary statistic and records the original file’s SHA-256 hash. Workflow artifacts retain the full samples.

Plot generation uses Matplotlib in the separate benchmark-report dependency group; it adds no dependency to timed benchmark runs or ordinary tests. The SVG files contain text labels and can be exported or shared separately. Both plot types are generated from the same committed summaries as the tables.

The generator rejects incomplete or duplicate case matrices. Review the source revision, dependency versions, measurement settings, and variability before committing refreshed data. Artifact retention is finite; the committed curated JSON preserves the measurements used by this page.

Baseline results🔗

These measurements come from workflow run 46599585718. Each table records its measured source revision, exact dependency versions, and environment. Some PyPy rounds take milliseconds despite microsecond medians; these outliers are retained and can make SD exceed the mean. These measurements do not identify the cause of the pauses.

Observed repetitions: 12,060–199,442 rounds per case, with 1–100 iterations per round. Warmup and calibration calls are additional.

Within-run SD/mean: 4.4%–3.7e+02% across cases, including outliers. This does not measure between-run variation.

Python 3.10🔗

CPython 3.10.22. Measured: 2026-12-01T07:37:03.945896+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C.

Dependencies: msgspec==0.23.0, orjson==3.13.0, pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

PyPy 3.10.16. Measured: 2026-12-01T07:44:46.165693+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C. PyPy release: 7.3.19.

Dependencies: pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

Times and variation🔗

Median operation times for Python 3.10

Timing statistics
Layer Workload Encoder Median (µs) IQR (µs) Mean ± SD (µs) Rounds × iterations
serialization simple json (CPython) 1.79 0.12 1.82 ± 0.22 64,654 × 10
serialization simple orjson (CPython) 0.234 0.0078 0.239 ± 0.019 43,831 × 100
serialization simple msgspec (CPython) 0.127 0.0028 0.13 ± 0.016 80,985 × 100
serialization simple json (PyPy) 0.323 0.019 0.334 ± 0.068 33,879 × 100
serialization structured json (CPython) 2.77 0.17 2.82 ± 0.27 41,532 × 10
serialization structured orjson (CPython) 0.366 0.03 0.378 ± 0.064 197,551 × 15
serialization structured msgspec (CPython) 0.273 0.011 0.278 ± 0.036 193,051 × 20
serialization structured json (PyPy) 0.679 0.04 0.702 ± 0.19 167,673 × 10
serialization nested json (CPython) 68.4 1.9 69.5 ± 3.5 15,040 × 1
serialization nested orjson (CPython) 13.1 0.32 13.3 ± 1.2 80,724 × 1
serialization nested msgspec (CPython) 8.85 0.37 8.97 ± 0.95 124,798 × 1
serialization nested json (PyPy) 57.6 3.9 59 ± 8.5 20,538 × 1
serialization unicode json (CPython) 2.97 0.2 3.03 ± 0.44 193,275 × 2
serialization unicode orjson (CPython) 0.88 0.014 0.894 ± 0.094 117,939 × 10
serialization unicode msgspec (CPython) 0.918 0.01 0.931 ± 0.093 112,931 × 10
serialization unicode json (PyPy) 1.72 0.057 1.76 ± 0.27 65,859 × 10
serialization rich json (CPython) 17.8 0.86 18.2 ± 1.9 62,213 × 1
serialization rich orjson (CPython) 3.94 0.22 4 ± 0.49 142,026 × 2
serialization rich msgspec (CPython) 2.35 0.12 2.39 ± 0.25 47,552 × 10
serialization rich json (PyPy) 8.62 0.46 8.99 ± 12 132,328 × 1
serialization exception json (CPython) 2.45 0.13 2.48 ± 0.22 48,251 × 10
serialization exception orjson (CPython) 0.313 0.017 0.32 ± 0.044 196,117 × 17
serialization exception msgspec (CPython) 0.259 0.0068 0.263 ± 0.034 192,123 × 21
serialization exception json (PyPy) 0.766 0.047 0.792 ± 0.21 146,650 × 10
formatting simple json (CPython) 3.74 0.3 3.81 ± 0.51 158,958 × 2
formatting simple orjson (CPython) 1.86 0.08 1.88 ± 0.16 60,209 × 10
formatting simple msgspec (CPython) 1.62 0.082 1.64 ± 0.15 69,455 × 10
formatting simple json (PyPy) 2.08 0.077 2.15 ± 1.1 51,862 × 10
formatting structured json (CPython) 5.76 0.37 5.84 ± 0.64 104,987 × 2
formatting structured orjson (CPython) 3 0.2 3.05 ± 0.43 196,541 × 2
formatting structured msgspec (CPython) 2.75 0.14 2.78 ± 0.2 42,143 × 10
formatting structured json (PyPy) 3.32 0.15 3.42 ± 3.1 166,224 × 2
formatting nested json (CPython) 69.7 2.2 70.7 ± 3.2 14,888 × 1
formatting nested orjson (CPython) 15.4 0.49 15.7 ± 1.3 69,171 × 1
formatting nested msgspec (CPython) 10.9 0.49 11.1 ± 1.1 102,020 × 1
formatting nested json (PyPy) 60 3.5 61.6 ± 12 19,231 × 1
formatting unicode json (CPython) 4.99 0.32 5.09 ± 0.61 116,551 × 2
formatting unicode orjson (CPython) 2.61 0.098 2.65 ± 0.18 42,445 × 10
formatting unicode msgspec (CPython) 2.62 0.097 2.65 ± 0.18 43,678 × 10
formatting unicode json (PyPy) 3.51 0.16 3.63 ± 3 159,949 × 2
formatting rich json (CPython) 21.5 1.2 21.9 ± 2 54,116 × 1
formatting rich orjson (CPython) 6.7 0.37 6.83 ± 0.9 165,563 × 1
formatting rich msgspec (CPython) 5.15 0.31 5.24 ± 0.6 109,818 × 2
formatting rich json (PyPy) 12.5 0.53 12.9 ± 7.5 87,101 × 1
formatting exception json (CPython) 24 1.2 24.4 ± 2.1 47,941 × 1
formatting exception orjson (CPython) 20.6 1.1 20.9 ± 1.9 56,313 × 1
formatting exception msgspec (CPython) 20.1 1.1 20.5 ± 2 58,511 × 1
formatting exception json (PyPy) 6.86 0.4 7.46 ± 28 166,890 × 1

Speedup🔗

Median speedups relative to stdlib JSON for Python 3.10

Reference: json (CPython) (1×).

Speedup values
Layer Workload json (CPython) orjson (CPython) msgspec (CPython) json (PyPy)
serialization simple 1× 7.7× 14× 5.5×
serialization structured 1× 7.6× 10× 4.1×
serialization nested 1× 5.2× 7.7× 1.2×
serialization unicode 1× 3.4× 3.2× 1.7×
serialization rich 1× 4.5× 7.6× 2.1×
serialization exception 1× 7.8× 9.5× 3.2×
formatting simple 1× 2× 2.3× 1.8×
formatting structured 1× 1.9× 2.1× 1.7×
formatting nested 1× 4.5× 6.4× 1.2×
formatting unicode 1× 1.9× 1.9× 1.4×
formatting rich 1× 3.2× 4.2× 1.7×
formatting exception 1× 1.2× 1.2× 3.5×

Python 3.11🔗

CPython 3.11.18. Measured: 2026-12-01T07:38:35.336014+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C.

Dependencies: msgspec==0.23.0, orjson==3.13.0, pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

PyPy 3.11.17. Measured: 2026-12-01T07:45:21.407527+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C. PyPy release: 8.0.1.

Dependencies: pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

Times and variation🔗

Median operation times for Python 3.11

Timing statistics
Layer Workload Encoder Median (µs) IQR (µs) Mean ± SD (µs) Rounds × iterations
serialization simple json (CPython) 1.41 0.14 1.46 ± 0.22 79,165 × 10
serialization simple orjson (CPython) 0.182 0.007 0.186 ± 0.015 56,732 × 100
serialization simple msgspec (CPython) 0.102 0.0021 0.104 ± 0.01 101,062 × 100
serialization simple json (PyPy) 0.363 0.026 0.378 ± 0.18 195,313 × 16
serialization structured json (CPython) 2.15 0.15 2.19 ± 0.21 51,335 × 10
serialization structured orjson (CPython) 0.3 0.023 0.308 ± 0.044 197,942 × 18
serialization structured msgspec (CPython) 0.233 0.011 0.238 ± 0.018 44,975 × 100
serialization structured json (PyPy) 0.912 0.06 0.94 ± 0.2 123,717 × 10
serialization nested json (CPython) 71.9 2.3 72.9 ± 4.5 14,522 × 1
serialization nested orjson (CPython) 13 0.41 13.2 ± 1.2 81,847 × 1
serialization nested msgspec (CPython) 8.89 0.38 9 ± 1 124,782 × 1
serialization nested json (PyPy) 82.9 2.7 84.9 ± 20 12,479 × 1
serialization unicode json (CPython) 2.66 0.14 2.7 ± 0.21 40,833 × 10
serialization unicode orjson (CPython) 0.82 0.012 0.836 ± 0.092 124,596 × 10
serialization unicode msgspec (CPython) 0.871 0.0073 0.883 ± 0.09 116,564 × 10
serialization unicode json (PyPy) 1.53 0.79 1.79 ± 0.45 77,233 × 10
serialization rich json (CPython) 14.1 0.79 14.4 ± 1.5 83,119 × 1
serialization rich orjson (CPython) 2.71 0.14 2.74 ± 0.21 40,740 × 10
serialization rich msgspec (CPython) 1.69 0.083 1.71 ± 0.15 65,211 × 10
serialization rich json (PyPy) 10.5 0.52 10.8 ± 4.6 107,666 × 1
serialization exception json (CPython) 1.92 0.13 1.96 ± 0.19 55,835 × 10
serialization exception orjson (CPython) 0.254 0.012 0.26 ± 0.019 40,606 × 100
serialization exception msgspec (CPython) 0.219 0.0028 0.223 ± 0.016 48,068 × 100
serialization exception json (PyPy) 0.8 0.061 0.827 ± 0.19 141,243 × 10
formatting simple json (CPython) 2.92 0.17 2.95 ± 0.23 40,904 × 10
formatting simple orjson (CPython) 1.36 0.082 1.38 ± 0.15 87,238 × 10
formatting simple msgspec (CPython) 1.2 0.062 1.22 ± 0.13 93,076 × 10
formatting simple json (PyPy) 2.05 0.082 2.11 ± 1.4 53,209 × 10
formatting structured json (CPython) 4.68 0.41 4.75 ± 0.61 129,585 × 2
formatting structured orjson (CPython) 2.1 0.1 2.13 ± 0.18 53,271 × 10
formatting structured msgspec (CPython) 1.96 0.077 1.99 ± 0.17 55,021 × 10
formatting structured json (PyPy) 3.4 0.16 3.51 ± 3.9 161,213 × 2
formatting nested json (CPython) 73.5 2.5 74.5 ± 3.3 14,315 × 1
formatting nested orjson (CPython) 14.9 0.58 15.2 ± 1.3 72,010 × 1
formatting nested msgspec (CPython) 10.6 0.55 10.8 ± 1.1 104,822 × 1
formatting nested json (PyPy) 86.4 3.4 88.1 ± 21 12,143 × 1
formatting unicode json (CPython) 4.47 0.35 4.56 ± 0.63 132,503 × 2
formatting unicode orjson (CPython) 2.16 0.14 2.19 ± 0.19 52,657 × 10
formatting unicode msgspec (CPython) 2.1 0.11 2.13 ± 0.18 51,760 × 10
formatting unicode json (PyPy) 3.45 0.75 3.7 ± 2.7 169,722 × 2
formatting rich json (CPython) 16.6 1 16.9 ± 1.8 70,642 × 1
formatting rich orjson (CPython) 5.07 0.42 5.16 ± 0.64 117,110 × 2
formatting rich msgspec (CPython) 4.02 0.4 4.09 ± 0.55 154,107 × 2
formatting rich json (PyPy) 13.9 0.58 14.4 ± 4.3 78,413 × 1
formatting exception json (CPython) 31.3 1.5 31.9 ± 2.5 36,299 × 1
formatting exception orjson (CPython) 28 1.5 28.5 ± 2.4 41,441 × 1
formatting exception msgspec (CPython) 27.8 1.5 28.2 ± 2.4 41,302 × 1
formatting exception json (PyPy) 14.3 0.56 15.4 ± 36 76,395 × 1

Speedup🔗

Median speedups relative to stdlib JSON for Python 3.11

Reference: json (CPython) (1×).

Speedup values
Layer Workload json (CPython) orjson (CPython) msgspec (CPython) json (PyPy)
serialization simple 1× 7.7× 14× 3.9×
serialization structured 1× 7.2× 9.2× 2.4×
serialization nested 1× 5.5× 8.1× 0.87×
serialization unicode 1× 3.2× 3.1× 1.7×
serialization rich 1× 5.2× 8.4× 1.4×
serialization exception 1× 7.6× 8.8× 2.4×
formatting simple 1× 2.2× 2.4× 1.4×
formatting structured 1× 2.2× 2.4× 1.4×
formatting nested 1× 4.9× 6.9× 0.85×
formatting unicode 1× 2.1× 2.1× 1.3×
formatting rich 1× 3.3× 4.1× 1.2×
formatting exception 1× 1.1× 1.1× 2.2×

Python 3.12🔗

CPython 3.12.16. Measured: 2026-12-01T07:39:59.256726+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C.

Dependencies: msgspec==0.23.0, orjson==3.13.0, pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

PyPy 3.12.15. Measured: 2026-12-01T07:45:56.632679+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C. PyPy release: 8.0.1.

Dependencies: pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

Times and variation🔗

Median operation times for Python 3.12

Timing statistics
Layer Workload Encoder Median (µs) IQR (µs) Mean ± SD (µs) Rounds × iterations
serialization simple json (CPython) 1.17 0.034 1.18 ± 0.11 89,526 × 10
serialization simple orjson (CPython) 0.176 0.0053 0.179 ± 0.015 58,347 × 100
serialization simple msgspec (CPython) 0.111 0.0019 0.112 ± 0.012 92,022 × 100
serialization simple json (PyPy) 0.387 0.031 0.404 ± 0.2 196,079 × 15
serialization structured json (CPython) 1.73 0.058 1.78 ± 0.22 61,069 × 10
serialization structured orjson (CPython) 0.291 0.021 0.301 ± 0.043 198,926 × 18
serialization structured msgspec (CPython) 0.249 0.0055 0.253 ± 0.016 41,277 × 100
serialization structured json (PyPy) 0.914 0.055 0.94 ± 0.16 121,611 × 10
serialization nested json (CPython) 44.4 0.84 45.1 ± 3 23,102 × 1
serialization nested orjson (CPython) 13 0.26 13.1 ± 1.1 80,698 × 1
serialization nested msgspec (CPython) 9.33 0.37 9.44 ± 0.94 120,773 × 1
serialization nested json (PyPy) 82.7 2.5 84.4 ± 4.6 12,544 × 1
serialization unicode json (CPython) 2.64 0.069 2.68 ± 0.19 39,876 × 10
serialization unicode orjson (CPython) 0.877 0.011 0.893 ± 0.11 115,996 × 10
serialization unicode msgspec (CPython) 0.933 0.0091 0.948 ± 0.12 109,135 × 10
serialization unicode json (PyPy) 1.49 0.75 1.71 ± 0.41 73,390 × 10
serialization rich json (CPython) 9.69 0.45 9.86 ± 1.5 115,768 × 1
serialization rich orjson (CPython) 2.09 0.13 2.13 ± 0.22 52,765 × 10
serialization rich msgspec (CPython) 1.29 0.069 1.32 ± 0.15 83,964 × 10
serialization rich json (PyPy) 10.5 0.49 10.8 ± 4.3 107,713 × 1
serialization exception json (CPython) 1.67 0.04 1.7 ± 0.18 62,182 × 10
serialization exception orjson (CPython) 0.248 0.0077 0.252 ± 0.019 41,458 × 100
serialization exception msgspec (CPython) 0.217 0.0028 0.221 ± 0.016 46,679 × 100
serialization exception json (PyPy) 0.82 0.074 0.846 ± 0.17 140,410 × 10
formatting simple json (CPython) 2.22 0.072 2.25 ± 0.18 48,963 × 10
formatting simple orjson (CPython) 1.15 0.048 1.16 ± 0.12 97,248 × 10
formatting simple msgspec (CPython) 1.05 0.039 1.06 ± 0.1 105,877 × 10
formatting simple json (PyPy) 2.12 0.079 2.2 ± 1.5 50,956 × 10
formatting structured json (CPython) 3.51 0.18 3.58 ± 0.49 154,727 × 2
formatting structured orjson (CPython) 1.84 0.07 1.87 ± 0.16 59,877 × 10
formatting structured msgspec (CPython) 1.8 0.056 1.82 ± 0.15 60,079 × 10
formatting structured json (PyPy) 3.45 0.14 3.57 ± 4.2 157,431 × 2
formatting nested json (CPython) 46 0.93 46.7 ± 2.4 22,420 × 1
formatting nested orjson (CPython) 14.2 0.33 14.4 ± 1.2 74,086 × 1
formatting nested msgspec (CPython) 10.5 0.43 10.7 ± 1 104,756 × 1
formatting nested json (PyPy) 86.4 3 88.3 ± 22 12,060 × 1
formatting unicode json (CPython) 3.82 0.14 3.89 ± 0.45 140,727 × 2
formatting unicode orjson (CPython) 1.91 0.064 1.93 ± 0.16 55,982 × 10
formatting unicode msgspec (CPython) 1.95 0.061 1.98 ± 0.15 54,636 × 10
formatting unicode json (PyPy) 3.43 0.22 3.61 ± 2.8 162,549 × 2
formatting rich json (CPython) 11.4 0.55 11.6 ± 1.3 97,428 × 1
formatting rich orjson (CPython) 3.89 0.22 3.96 ± 0.5 144,467 × 2
formatting rich msgspec (CPython) 3.11 0.22 3.16 ± 0.42 188,360 × 2
formatting rich json (PyPy) 14.1 0.55 14.6 ± 8 77,900 × 1
formatting exception json (CPython) 22.6 1.1 23.1 ± 2.5 50,181 × 1
formatting exception orjson (CPython) 20 1.1 20.4 ± 2.2 57,921 × 1
formatting exception msgspec (CPython) 20.2 1.1 20.6 ± 2.4 57,784 × 1
formatting exception json (PyPy) 15.1 0.59 16.3 ± 38 72,807 × 1

Speedup🔗

Median speedups relative to stdlib JSON for Python 3.12

Reference: json (CPython) (1×).

Speedup values
Layer Workload json (CPython) orjson (CPython) msgspec (CPython) json (PyPy)
serialization simple 1× 6.6× 11× 3×
serialization structured 1× 5.9× 6.9× 1.9×
serialization nested 1× 3.4× 4.8× 0.54×
serialization unicode 1× 3× 2.8× 1.8×
serialization rich 1× 4.6× 7.5× 0.93×
serialization exception 1× 6.7× 7.7× 2×
formatting simple 1× 1.9× 2.1× 1×
formatting structured 1× 1.9× 2× 1×
formatting nested 1× 3.2× 4.4× 0.53×
formatting unicode 1× 2× 2× 1.1×
formatting rich 1× 2.9× 3.7× 0.81×
formatting exception 1× 1.1× 1.1× 1.5×

Python 3.13🔗

CPython 3.13.18. Measured: 2026-12-01T07:41:25.547272+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C.

Dependencies: msgspec==0.23.0, orjson==3.13.0, pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

Times and variation🔗

Median operation times for Python 3.13

Timing statistics
Layer Workload Encoder Median (µs) IQR (µs) Mean ± SD (µs) Rounds × iterations
serialization simple json (CPython) 1.23 0.08 1.25 ± 0.13 88,153 × 10
serialization simple orjson (CPython) 0.189 0.0062 0.197 ± 0.028 55,191 × 100
serialization simple msgspec (CPython) 0.106 0.003 0.108 ± 0.011 97,925 × 100
serialization structured json (CPython) 1.77 0.077 1.8 ± 0.16 60,783 × 10
serialization structured orjson (CPython) 0.306 0.02 0.312 ± 0.04 193,987 × 18
serialization structured msgspec (CPython) 0.236 0.0066 0.242 ± 0.022 43,505 × 100
serialization nested json (CPython) 49.4 0.86 50.1 ± 3 20,954 × 1
serialization nested orjson (CPython) 12.5 0.34 12.7 ± 1.3 85,129 × 1
serialization nested msgspec (CPython) 9.14 0.31 9.25 ± 1.3 120,788 × 1
serialization unicode json (CPython) 2.66 0.08 2.69 ± 0.22 40,174 × 10
serialization unicode orjson (CPython) 0.876 0.011 0.889 ± 0.11 116,523 × 10
serialization unicode msgspec (CPython) 0.917 0.0085 0.93 ± 0.1 110,730 × 10
serialization rich json (CPython) 11.4 0.68 11.5 ± 1.3 105,553 × 1
serialization rich orjson (CPython) 2.31 0.15 2.33 ± 0.19 50,508 × 10
serialization rich msgspec (CPython) 1.34 0.09 1.37 ± 0.14 81,767 × 10
serialization exception json (CPython) 1.7 0.065 1.72 ± 0.14 62,989 × 10
serialization exception orjson (CPython) 0.267 0.011 0.272 ± 0.036 199,442 × 20
serialization exception msgspec (CPython) 0.223 0.0057 0.228 ± 0.017 46,030 × 100
formatting simple json (CPython) 2.48 0.12 2.5 ± 0.19 45,803 × 10
formatting simple orjson (CPython) 1.29 0.066 1.3 ± 0.13 92,124 × 10
formatting simple msgspec (CPython) 1.13 0.064 1.15 ± 0.14 102,146 × 10
formatting structured json (CPython) 3.81 0.31 3.86 ± 0.5 156,593 × 2
formatting structured orjson (CPython) 1.85 0.085 1.87 ± 0.15 62,512 × 10
formatting structured msgspec (CPython) 1.69 0.077 1.71 ± 0.15 67,065 × 10
formatting nested json (CPython) 49.5 1 50.4 ± 2.9 20,942 × 1
formatting nested orjson (CPython) 13.5 0.37 13.7 ± 1.2 78,187 × 1
formatting nested msgspec (CPython) 10.4 0.44 10.6 ± 1 106,237 × 1
formatting unicode json (CPython) 4.06 0.25 4.14 ± 0.48 137,439 × 2
formatting unicode orjson (CPython) 2.05 0.073 2.08 ± 0.15 54,762 × 10
formatting unicode msgspec (CPython) 2.04 0.064 2.07 ± 0.15 53,342 × 10
formatting rich json (CPython) 13.2 0.82 13.4 ± 1.4 90,229 × 1
formatting rich orjson (CPython) 4.36 0.44 4.44 ± 0.58 139,393 × 2
formatting rich msgspec (CPython) 3.36 0.33 3.41 ± 0.46 181,324 × 2
formatting exception json (CPython) 40.4 1.3 41.2 ± 3.2 26,535 × 1
formatting exception orjson (CPython) 38 1.3 38.7 ± 3 28,269 × 1
formatting exception msgspec (CPython) 37.5 1.3 38.3 ± 2.9 28,852 × 1

Speedup🔗

Median speedups relative to stdlib JSON for Python 3.13

Reference: json (CPython) (1×).

Speedup values
Layer Workload json (CPython) orjson (CPython) msgspec (CPython)
serialization simple 1× 6.5× 12×
serialization structured 1× 5.8× 7.5×
serialization nested 1× 3.9× 5.4×
serialization unicode 1× 3× 2.9×
serialization rich 1× 4.9× 8.5×
serialization exception 1× 6.3× 7.6×
formatting simple 1× 1.9× 2.2×
formatting structured 1× 2.1× 2.3×
formatting nested 1× 3.7× 4.7×
formatting unicode 1× 2× 2×
formatting rich 1× 3× 3.9×
formatting exception 1× 1.1× 1.1×

Python 3.14🔗

CPython 3.14.4. Measured: 2026-12-01T07:42:47.169165+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C.

Dependencies: msgspec==0.23.0, orjson==3.13.0, pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

Times and variation🔗

Median operation times for Python 3.14

Timing statistics
Layer Workload Encoder Median (µs) IQR (µs) Mean ± SD (µs) Rounds × iterations
serialization simple json (CPython) 1.25 0.03 1.26 ± 0.12 83,872 × 10
serialization simple orjson (CPython) 0.187 0.0024 0.19 ± 0.014 54,681 × 100
serialization simple msgspec (CPython) 0.116 0.0018 0.118 ± 0.011 88,724 × 100
serialization structured json (CPython) 1.83 0.049 1.86 ± 0.18 58,069 × 10
serialization structured orjson (CPython) 0.296 0.0085 0.301 ± 0.041 196,503 × 18
serialization structured msgspec (CPython) 0.257 0.0096 0.261 ± 0.017 40,765 × 100
serialization nested json (CPython) 50 1.4 50.9 ± 2.5 20,798 × 1
serialization nested orjson (CPython) 12 0.39 12.2 ± 1.1 88,246 × 1
serialization nested msgspec (CPython) 9.06 0.23 9.15 ± 0.87 119,020 × 1
serialization unicode json (CPython) 2.2 0.048 2.22 ± 0.16 47,410 × 10
serialization unicode orjson (CPython) 0.725 0.015 0.736 ± 0.11 145,794 × 10
serialization unicode msgspec (CPython) 0.752 0.013 0.762 ± 0.084 138,832 × 10
serialization rich json (CPython) 9.74 0.47 9.91 ± 1.2 113,495 × 1
serialization rich orjson (CPython) 2 0.099 2.02 ± 0.19 55,430 × 10
serialization rich msgspec (CPython) 1.25 0.066 1.27 ± 0.16 86,170 × 10
serialization exception json (CPython) 1.72 0.036 1.75 ± 0.15 60,519 × 10
serialization exception orjson (CPython) 0.252 0.0041 0.257 ± 0.025 41,055 × 100
serialization exception msgspec (CPython) 0.239 0.0052 0.244 ± 0.018 43,594 × 100
formatting simple json (CPython) 2.29 0.059 2.33 ± 0.18 46,288 × 10
formatting simple orjson (CPython) 1.13 0.032 1.15 ± 0.12 95,703 × 10
formatting simple msgspec (CPython) 1.02 0.032 1.03 ± 0.11 104,570 × 10
formatting structured json (CPython) 3.39 0.13 3.46 ± 0.48 161,604 × 2
formatting structured orjson (CPython) 1.66 0.061 1.69 ± 0.17 65,916 × 10
formatting structured msgspec (CPython) 1.61 0.064 1.63 ± 0.16 67,264 × 10
formatting nested json (CPython) 51 1.3 51.9 ± 2.9 20,291 × 1
formatting nested orjson (CPython) 13.5 0.4 13.7 ± 1.2 78,983 × 1
formatting nested msgspec (CPython) 10.4 0.27 10.5 ± 0.97 104,921 × 1
formatting unicode json (CPython) 3.42 0.11 3.5 ± 0.5 158,630 × 2
formatting unicode orjson (CPython) 1.75 0.047 1.79 ± 0.17 62,054 × 10
formatting unicode msgspec (CPython) 1.75 0.046 1.78 ± 0.15 60,118 × 10
formatting rich json (CPython) 11.5 0.5 11.7 ± 1.4 94,527 × 1
formatting rich orjson (CPython) 3.82 0.19 3.89 ± 0.51 149,679 × 2
formatting rich msgspec (CPython) 3.02 0.19 3.08 ± 0.48 192,679 × 2
formatting exception json (CPython) 44.6 1.4 45.5 ± 3.2 24,174 × 1
formatting exception orjson (CPython) 41.7 1.3 42.5 ± 3.1 25,975 × 1
formatting exception msgspec (CPython) 41.5 1.3 42.3 ± 3.1 26,206 × 1

Speedup🔗

Median speedups relative to stdlib JSON for Python 3.14

Reference: json (CPython) (1×).

Speedup values
Layer Workload json (CPython) orjson (CPython) msgspec (CPython)
serialization simple 1× 6.7× 11×
serialization structured 1× 6.2× 7.1×
serialization nested 1× 4.2× 5.5×
serialization unicode 1× 3× 2.9×
serialization rich 1× 4.9× 7.8×
serialization exception 1× 6.8× 7.2×
formatting simple 1× 2× 2.3×
formatting structured 1× 2× 2.1×
formatting nested 1× 3.8× 4.9×
formatting unicode 1× 2× 2×
formatting rich 1× 3× 3.8×
formatting exception 1× 1.1× 1.1×

Python 3.15🔗

CPython 3.15.2. Measured: 2026-12-01T07:44:08.829000+00:00. Revision: 121649794d18b083f3f800cfbdc572b04d85fff4.

Environment: Linux 7.0.0-1018-aws, x86_64; Intel(R) Xeon(R) 6975P-C.

Dependencies: msgspec==0.23.0, orjson==3.13.0, pytest==9.1.1, pytest-benchmark==5.3.1, python-json-logger==4.3.0.dev4.

Times and variation🔗

Median operation times for Python 3.15

Timing statistics
Layer Workload Encoder Median (µs) IQR (µs) Mean ± SD (µs) Rounds × iterations
serialization simple json (CPython) 1.2 0.039 1.22 ± 0.12 88,394 × 10
serialization simple orjson (CPython) 0.19 0.0056 0.194 ± 0.015 53,996 × 100
serialization simple msgspec (CPython) 0.114 0.0014 0.116 ± 0.011 89,230 × 100
serialization structured json (CPython) 1.74 0.063 1.8 ± 0.28 61,283 × 10
serialization structured orjson (CPython) 0.306 0.027 0.316 ± 0.052 195,542 × 18
serialization structured msgspec (CPython) 0.256 0.0089 0.26 ± 0.023 40,767 × 100
serialization nested json (CPython) 41.1 0.72 41.7 ± 3 25,266 × 1
serialization nested orjson (CPython) 12.7 0.37 12.9 ± 12 83,914 × 1
serialization nested msgspec (CPython) 8.99 0.25 9.11 ± 1.4 118,765 × 1
serialization unicode json (CPython) 2.52 0.047 2.56 ± 0.53 41,176 × 10
serialization unicode orjson (CPython) 0.752 0.014 0.764 ± 0.095 138,466 × 10
serialization unicode msgspec (CPython) 0.798 0.011 0.81 ± 0.1 128,916 × 10
serialization rich json (CPython) 8.91 0.4 9.06 ± 1.3 125,644 × 1
serialization rich orjson (CPython) 1.82 0.083 1.85 ± 0.16 60,585 × 10
serialization rich msgspec (CPython) 1.2 0.056 1.22 ± 0.14 88,992 × 10
serialization exception json (CPython) 1.62 0.039 1.65 ± 0.14 63,980 × 10
serialization exception orjson (CPython) 0.246 0.011 0.251 ± 0.018 41,970 × 100
serialization exception msgspec (CPython) 0.217 0.0023 0.22 ± 0.016 47,097 × 100
formatting simple json (CPython) 2.2 0.069 2.23 ± 0.18 48,910 × 10
formatting simple orjson (CPython) 1.08 0.042 1.1 ± 0.12 98,513 × 10
formatting simple msgspec (CPython) 0.967 0.029 0.98 ± 0.1 108,826 × 10
formatting structured json (CPython) 3.27 0.16 3.33 ± 1.1 170,853 × 2
formatting structured orjson (CPython) 1.65 0.057 1.67 ± 0.16 66,410 × 10
formatting structured msgspec (CPython) 1.55 0.047 1.57 ± 0.13 68,232 × 10
formatting nested json (CPython) 42.6 0.82 43.3 ± 2.7 24,356 × 1
formatting nested orjson (CPython) 13.9 0.45 14.2 ± 1.3 75,621 × 1
formatting nested msgspec (CPython) 10.2 0.31 10.3 ± 1 105,631 × 1
formatting unicode json (CPython) 3.65 0.12 3.71 ± 0.6 148,127 × 2
formatting unicode orjson (CPython) 1.82 0.071 1.85 ± 0.16 59,358 × 10
formatting unicode msgspec (CPython) 1.77 0.045 1.8 ± 0.15 59,475 × 10
formatting rich json (CPython) 10.5 0.45 10.7 ± 1.5 104,910 × 1
formatting rich orjson (CPython) 3.57 0.18 3.64 ± 0.63 158,756 × 2
formatting rich msgspec (CPython) 2.82 0.15 2.87 ± 0.43 198,650 × 2
formatting exception json (CPython) 44.6 1.2 45.6 ± 3.8 24,119 × 1
formatting exception orjson (CPython) 41.9 1.2 42.8 ± 3.3 25,881 × 1
formatting exception msgspec (CPython) 41.6 1.2 42.5 ± 3.3 25,715 × 1

Speedup🔗

Median speedups relative to stdlib JSON for Python 3.15

Reference: json (CPython) (1×).

Speedup values
Layer Workload json (CPython) orjson (CPython) msgspec (CPython)
serialization simple 1× 6.3× 11×
serialization structured 1× 5.7× 6.8×
serialization nested 1× 3.2× 4.6×
serialization unicode 1× 3.4× 3.2×
serialization rich 1× 4.9× 7.4×
serialization exception 1× 6.6× 7.5×
formatting simple 1× 2× 2.3×
formatting structured 1× 2× 2.1×
formatting nested 1× 3.1× 4.2×
formatting unicode 1× 2× 2.1×
formatting rich 1× 2.9× 3.7×
formatting exception 1× 1.1× 1.1×