Skip to content

Performance Benchmarks

jsonatapy is a high-performance Rust implementation of JSONata with Python bindings. This page presents benchmark comparisons against other JSONata implementations.

These numbers come from a dedicated, self-hosted Mac Mini (Apple Silicon), not a shared cloud CI runner — single-tenant physical hardware with no other workloads competing for CPU. This matters: single-sample measurements on a shared/virtualized runner were previously noisy enough that identical code, measured twice, swung -66% to +120%. Every number below is also the minimum of 5 independent measurement trials per test (not an average) — for CPU-bound microbenchmarks, interference can only make a run slower than the code's true achievable speed, never faster, so the minimum across repeated trials is the best available estimate of that true speed.

Implementations Tested

Implementation Language Version Description
jsonatapy Rust + Python 2.3.1 This project (compiled Rust extension via PyO3); data crosses the boundary as Python dicts
jsonatapy (JSON string I/O) Rust + Python 2.3.1 Same library via evaluate_json: data crosses as JSON strings, parsed/serialized by serde per call
jsonata-core (pure Rust) Rust 2.3.1 This project's engine measured as a Rust library — no Python at all, data pre-parsed, expression pre-compiled (criterion methodology, per table row)
jsonata-js JavaScript 2.3.1 Reference implementation (Node.js v20.20.2)
jsonata-python Python unknown Python wrapper embedding a JS engine (Duktape)
jsonata-rs Rust 0.3 Third-party Rust implementation (Stedi's crate — not this project; CLI harness, no Python overhead)

Methodology: compile-once, evaluate-many

Every implementation below is measured the way a real caller who evaluates the same expression repeatedly would use it, not its slowest possible one-off call:

  • jsonatapy — jsonatapy.compile(expr) once, then .evaluate(data) in the timed loop. No further reuse is available; the compiled bytecode is already cached on the expression object.
  • jsonata-core (pure Rust) — Expression::compile(expr) once, input parsed to a JValue once, then Expression::evaluate(&data) in an in-process timed loop with warmup — the same methodology as the criterion suite (benches/), reported per table row. The gap between this column and the jsonatapy columns is the Python boundary cost; the engine is identical.
  • jsonata-js — jsonata(expr) once, then .evaluate(data) in the timed loop. Same story: this is already the library's fastest repeated-call path.

  • jsonata-python — uses its documented Context object (ctx = jsonata.Context(), then ctx(expr, data) in the loop) rather than the one-off transform() convenience function. transform() re-bootstraps an embedded Duktape engine — reloading the jsonata.js library into it — on every single call; reusing a Context keeps that engine warm and is the library's own documented path for repeated evaluation. It is not a true compile-once equivalent, since Context.__call__ still re-parses the expression string on every call, so some of the remaining gap to jsonatapy/jsonata-js is real parsing cost this library doesn't let a caller amortize away.

Benchmarks run on 2026-12-03.

Summary by Category

Category jsonatapy vs JS
Simple Paths 5.5x faster
Array Operations 3.8x faster
Complex Transformations 8.1x faster
Deep Nesting 3.3x faster
String Operations 6.9x faster
Higher-Order Functions 11.9x faster
Realistic Workload 9.5x faster

Detailed Results

Simple Paths

Operation Data Size jsonatapy jsonatapy (json I/O) jsonata-core (pure Rust) jsonata-js jsonata-python jsonata-rs vs JS
Simple Path tiny 3.416 4.577 0.691 16.990 1830.263 60.828 5.0x faster
Deep Path (5 levels) tiny 4.316 6.850 1.041 25.850 3012.484 71.295 6.0x faster
Array Index Access 100 elements 5.321 9.329 1.465 11.230 938.261 96.756 2.1x faster
Arithmetic Expression tiny 2.477 3.896 0.718 22.230 2608.307 55.829 9.0x faster

Array Operations

Operation Data Size jsonatapy jsonatapy (json I/O) jsonata-core (pure Rust) jsonata-js jsonata-python jsonata-rs vs JS
Array Sum (100 elements) 100 elements 1.547 2.368 0.768 6.840 304.295 19.961 4.4x faster
Array Max (100 elements) 100 elements 1.316 2.136 0.529 6.260 297.818 20.002 4.8x faster
Array Count (100 elements) 100 elements 2.106 3.740 0.530 8.840 529.122 38.940 4.2x faster
Array Sum (1000 elements) 1000 elements 2.463 3.994 1.052 4.690 180.232 28.420 1.9x faster
Array Max (1000 elements) 1000 elements 1.969 3.502 0.556 3.880 166.881 28.438 2.0x faster
Array Sum (10000 elements) 10000 elements 6.020 10.093 2.521 8.850 353.726 70.383 1.5x faster
Array Mapping (extract field) 100 objects 7.908 26.990 1.255 21.520 2674.249 206.368 2.7x faster
Array Mapping + Sum 100 objects 7.589 26.160 1.974 24.810 2982.891 206.418 3.3x faster
Array Filtering (predicate) 100 objects 5.257 17.069 2.042 50.690 6750.608 107.365 9.6x faster

Complex Transformations

Operation Data Size jsonatapy jsonatapy (json I/O) jsonata-core (pure Rust) jsonata-js jsonata-python jsonata-rs vs JS
Object Construction (simple) tiny 3.948 3.788 2.941 27.230 2532.589 33.530 6.9x faster
Object Construction (nested) tiny 6.024 5.089 4.326 33.270 2899.665 36.372 5.5x faster
Conditional Expression tiny 1.119 1.684 0.409 13.710 1354.088 25.953 12.3x faster
Multiple Nested Functions tiny 2.543 2.930 2.732 19.250 1774.112 27.481 7.6x faster

Deep Nesting

Operation Data Size jsonatapy jsonatapy (json I/O) jsonata-core (pure Rust) jsonata-js jsonata-python jsonata-rs vs JS
Deep Path (12 levels) 12 levels 4.582 6.487 1.014 25.900 2914.227 54.536 5.7x faster
Nested Array Access 4-level nested arrays 8.905 13.432 0.658 7.910 608.745 107.246 1.1x slower

String Operations

Operation Data Size jsonatapy jsonatapy (json I/O) jsonata-core (pure Rust) jsonata-js jsonata-python jsonata-rs vs JS
String Uppercase tiny 3.919 4.660 3.271 22.760 2395.161 52.463 5.8x faster
String Lowercase tiny 3.939 4.687 3.268 22.410 2398.744 52.599 5.7x faster
String Length tiny 3.595 4.382 2.734 24.530 2595.662 54.179 6.8x faster
String Concatenation tiny 3.081 3.210 2.808 25.310 1922.847 29.729 8.2x faster
String Substring tiny 2.826 3.274 2.962 19.600 1685.764 28.105 6.9x faster
String Contains tiny 2.111 2.524 1.666 16.240 1416.990 27.868 7.7x faster

Higher-Order Functions

Operation Data Size jsonatapy jsonatapy (json I/O) jsonata-core (pure Rust) jsonata-js jsonata-python jsonata-rs vs JS
$map with lambda 100 elements 1.619 1.799 1.552 23.720 2683.984 7.538 14.6x faster
$filter with lambda 100 elements 1.684 1.849 1.492 23.580 2687.529 7.371 14.0x faster
$reduce with lambda 100 elements 3.175 3.302 3.040 22.730 2697.048 8.077 7.2x faster

Realistic Workload

Operation Data Size jsonatapy jsonatapy (json I/O) jsonata-core (pure Rust) jsonata-js jsonata-python jsonata-rs vs JS
Filter by category 100 products 7.701 42.411 2.171 50.600 7441.364 314.407 6.6x faster
Calculate total value 100 products 7.787 41.453 4.174 37.980 5161.259 314.693 4.9x faster
Complex transformation 100 products 14.685 24.334 8.882 85.520 9321.627 135.532 5.8x faster
Group by category (aggregate) 100 products 11.640 24.120 7.787 88.440 N/A 133.441 7.6x faster
Top rated products 100 products 1.622 9.270 1.081 37.010 4528.245 66.798 22.8x faster

Path Comparison

Operation jsonatapy (ms) Iterations
Filter by category (data handle) 11.886 500
Filter by category (data→json) 5.680 500
Complex transformation (data handle) 27.993 500
Complex transformation (data→json) 23.765 500
Aggregate (data handle) 4.690 500
Aggregate (data→json) 4.710 500

Performance Characteristics

Faster than JavaScript:

  • Simple Paths (5.5x faster)
  • Array Operations (3.8x faster)
  • Complex Transformations (8.1x faster)
  • Deep Nesting (3.3x faster)
  • String Operations (6.9x faster)
  • Higher-Order Functions (11.9x faster)
  • Realistic Workload (9.5x faster)

Comparable to JavaScript:

  • (none this run)

Optimizing Array Workloads

For array-heavy workloads, the dominant cost is converting Python dicts to Rust values on every call. Use JsonataData to pre-convert data once and reuse across multiple evaluations:

import jsonatapy

data = {...}  # your data
expr = jsonatapy.compile("products[price > 100]")

# Pre-convert once
jdata = jsonatapy.JsonataData(data)

# Reuse many times (3-15x faster than evaluate(dict))
result = expr.evaluate_with_data(jdata)

Methodology

  • Date: 2026-12-03
  • Platform: GitHub Actions (self-hosted Michaels-Mini, physical/dedicated hardware, macOS ARM64)
  • Python: 3.14.6
  • Node.js: v20.20.2
  • All times are total wall-clock time for the stated number of iterations
  • Each benchmark includes a warmup phase before measurement
  • 'vs JS' column shows jsonatapy speedup relative to the JavaScript reference implementation
  • Values > 1x mean jsonatapy is faster; < 1x means JavaScript is faster