Python bindings for the datalogic-rs JSONLogic engine — compile-once, evaluate-many.
Project description
datalogic-py
Python bindings for datalogic-rs,
a fast Rust implementation of JSONLogic. Same
rules, same semantics as the Rust crate, with the compile-once /
evaluate-many pattern exposed natively — compile a rule once and
evaluate it against thousands of data inputs without re-parsing.
For the cross-runtime overview and the API-tier model every binding implements, see the repo README.
New in v5.
datalogic-pyis new — there is no v4 Python package. If you were calling the v4 Rust crate or the v4@goplasmatic/datalogicWASM package, the engine's v4 → v5 changes are catalogued in MIGRATION.md.
Install
pip install datalogic-py
Pre-built wheels are published for:
| Platform | Architectures |
|---|---|
| Linux (manylinux) | x86_64, aarch64 |
| Linux (musllinux) | x86_64, aarch64 |
| macOS | x86_64, arm64 |
| Windows | x86_64 |
Python 3.10 and newer are supported via
PEP 384 stable ABI (abi3) — one
wheel per platform covers every CPython 3.10+ release.
Naming:
pip install datalogic-py(PyPI distribution name) →import datalogic_py(Python module name). Python modules can't contain hyphens, so the underscore form is the import.
Quick start
from datalogic_py import apply
result = apply(
{"if": [{">": [{"var": "score"}, 50]}, "pass", "fail"]},
{"score": 75},
)
# -> "pass"
API reference
The Python binding mirrors the Rust engine's API tier model.
| Tier | Entry point | Use when |
|---|---|---|
| One-shot | apply(rule, data) |
Ad-hoc evaluation, one rule + one data shape |
| Engine | Engine().eval(rule, data) |
Custom configuration (templating, future operator extensions) |
| Compile once | Engine().compile(rule).evaluate(data) |
Same rule evaluated against many data inputs |
| Session | with engine.session() as sess: … |
Hot loops — amortise arena reset across iterations |
One-shot — apply(rule, data)
from datalogic_py import apply
apply({"+": [1, 2, 3]}, {}) # 6
apply({"var": "user.age"}, {"user": {"age": 25}}) # 25
apply({"and": [{">": [{"var": "x"}, 0]}, True]}, {"x": 5}) # True
Both arguments accept Python dict / list values (converted via
pythonize, roughly 3–10× faster
than a JSON-string round-trip). For payloads with types pythonize
doesn't cover, see Type conversion below.
Engine — Engine().eval(rule, data)
Construct an Engine when you need templating mode or any non-default
configuration:
from datalogic_py import Engine
engine = Engine() # default config
engine.eval({"==": [1, 1]}, {}) # True
# Templating mode — multi-key objects become output templates
templating_engine = Engine(templating=True)
templating_engine.eval(
{"name": {"var": "user.name"}, "ok": {">": [{"var": "score"}, 50]}},
{"user": {"name": "Ada"}, "score": 99},
)
# {"name": "Ada", "ok": True}
Compile once — Engine().compile(rule) → Rule.evaluate(data)
Compile the rule once when you'll evaluate it against many data inputs.
from datalogic_py import Engine
engine = Engine()
rule = engine.compile({"if": [{">": [{"var": "score"}, 50]}, "pass", "fail"]})
for payload in batch:
result = rule.evaluate(payload) # accepts a dict
fast = rule.evaluate_str(json_text) # accepts a JSON string (skips dict conversion)
Rule is thread-safe — clone the reference into worker threads and
evaluate concurrently. The Rust eval call releases the GIL, so a
multi-threaded server gains real parallelism.
Session — hot loops
For batches where you want to amortise arena reset across iterations,
open a Session. The arena is reset between iterations automatically.
from datalogic_py import Engine
engine = Engine()
rule = engine.compile({"+": [{"var": "x"}, 1]})
with engine.session() as sess:
for payload in batch:
result = sess.evaluate(rule, payload)
Session is the per-thread workhorse — open one per worker thread.
The arena that makes it fast can't be shared across threads (the same
way a database connection is per-task in a connection-pool model);
Engine and Rule are both thread-safe, so share those.
Error handling
All exceptions descend from DataLogicError:
| Exception | When |
|---|---|
ParseError |
Malformed rule or data JSON, unsupported operator, or unsupported Python type |
EvaluateError |
Operator failure at runtime — carries .error_type, .operator, .path |
from datalogic_py import Engine, EvaluateError
engine = Engine()
try:
engine.eval({"var": "missing"}, {})
except EvaluateError as e:
print(e.error_type) # e.g. "VariableNotFound"
print(e.operator) # "var"
print(e.path) # JSON-pointer-style path through the compiled tree
Threading
| Type | Pattern |
|---|---|
Engine |
Build once; share across threads |
Rule |
Compile once; share across threads — evaluate releases the GIL for parallelism |
Session |
One per worker thread — the per-task workhorse |
Type conversion
The dict-input path uses pythonize:
Supported: dict, list, str, int, float, bool, None.
Not supported — these raise ParseError with a clear message:
datetime.datetime,datetime.date— convert to ISO string at the Python edgedecimal.Decimal— convert tofloatorstrbytes,set,tuplefloat('nan'),float('inf')— JSON spec disallows them
For payloads with exotic types, use rule.evaluate_str(json_text) and
bring your own JSON encoder (e.g. with default=str).
Templating mode
engine = Engine(templating=True)
rule = engine.compile({
"name": {"var": "user.name"},
"ok": {">": [{"var": "score"}, 50]},
})
rule.evaluate({"user": {"name": "Ada"}, "score": 99})
# -> {"name": "Ada", "ok": True}
Performance
This package wraps the same Rust engine measured as dlrs:engine in the
cross-library benchmark — geomean 9.7 ns/op across 44 operator
suites in native Rust. The pyo3 boundary and pythonize dict
conversion add a small per-call cost on top; use
rule.evaluate_str(json_text) when you already have a JSON string and
want to skip the dict path. evaluate releases the GIL, so a
multi-threaded server gains real parallelism on top of the engine's
native speed.
Learn more
- Repo README — cross-runtime overview, all binding READMEs
- Rust crate README — engine design, custom operators, configuration knobs
- Full documentation — long-form guide, operator reference
- Online playground
- JSONLogic specification
License
Apache-2.0. See the main repository for source and contribution guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datalogic_py-5.0.0.tar.gz.
File metadata
- Download URL: datalogic_py-5.0.0.tar.gz
- Upload date:
- Size: 237.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
756ff99d1a81c3bac0d4ec312cd32ff43e34321436eb17c121ea3f281b56133b
|
|
| MD5 |
f8b50de8e621a4e2be2a1dacc37adadf
|
|
| BLAKE2b-256 |
5d0f1614aaa78c3c15f7aa53f7939c8a15610b8586f36dad9066c7190ffd111f
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0.tar.gz:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0.tar.gz -
Subject digest:
756ff99d1a81c3bac0d4ec312cd32ff43e34321436eb17c121ea3f281b56133b - Sigstore transparency entry: 1534614148
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datalogic_py-5.0.0-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: datalogic_py-5.0.0-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ddd37e20af0eae38a8d62822fd79a6a23a1010ca5c4cf0ff9539ea8649f4db4
|
|
| MD5 |
eb9d6c898695bd6c671c922b1b6dd6d2
|
|
| BLAKE2b-256 |
cdd32a867fb1bcfb708e6feac6761dfb0610b864253809092be3a79899648684
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0-cp310-abi3-win_arm64.whl:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0-cp310-abi3-win_arm64.whl -
Subject digest:
1ddd37e20af0eae38a8d62822fd79a6a23a1010ca5c4cf0ff9539ea8649f4db4 - Sigstore transparency entry: 1534614435
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datalogic_py-5.0.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: datalogic_py-5.0.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ca293afff784a8b8342ada223340fde1343a57d5ba9916e3f884d413609fbcf
|
|
| MD5 |
96647856c8453fa958bcfe2a7f843ece
|
|
| BLAKE2b-256 |
88ade2678997f9193225a757866081fb89c5fb9311f9dc26f5ae57ad2b31ffa9
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0-cp310-abi3-win_amd64.whl -
Subject digest:
1ca293afff784a8b8342ada223340fde1343a57d5ba9916e3f884d413609fbcf - Sigstore transparency entry: 1534614768
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9f0f83e1d8379933715cc92f863ffd817cfb17024075adc848aa03c9f4287ce
|
|
| MD5 |
08a7781f2401ffde4694fb0315205cba
|
|
| BLAKE2b-256 |
3504d88acca02e2432006f92202fbefa7b93d86b97f95e5e50d1881dfac71e19
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
e9f0f83e1d8379933715cc92f863ffd817cfb17024075adc848aa03c9f4287ce - Sigstore transparency entry: 1534614661
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.10+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5940f09c92493c2870ac38eb0756eaaa1649a89e16bb00c9b47d490a3d7910d
|
|
| MD5 |
747b5d025fa0fb7b83cd63aed53cd22e
|
|
| BLAKE2b-256 |
ba16d7dcb0ffa1a3a8d92d305a77d4951ed2b098f54f6157da198a78d953acb2
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_aarch64.whl:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0-cp310-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
f5940f09c92493c2870ac38eb0756eaaa1649a89e16bb00c9b47d490a3d7910d - Sigstore transparency entry: 1534614587
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99ba171ec336a39063fb71fad1550de1b3f1e538a7fffe316b62fcf39b3c0113
|
|
| MD5 |
ebb8741116237fd17061d0115f6629c8
|
|
| BLAKE2b-256 |
5259f8b785a77edff4a5f3108dd0ebd497c4250e8bd01df738cd8d51f15946b1
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
99ba171ec336a39063fb71fad1550de1b3f1e538a7fffe316b62fcf39b3c0113 - Sigstore transparency entry: 1534614224
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c144d697965ddb35c5dfd6f44c5adbb4698888681cf8b6ccfd217eb6db25c5a
|
|
| MD5 |
f161995365fb50bf6b1d0acf205b1399
|
|
| BLAKE2b-256 |
6d4851c740ffb275a73cbf8998ab1ecf7ba911a67b95f9fc73ec950171682ef4
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
4c144d697965ddb35c5dfd6f44c5adbb4698888681cf8b6ccfd217eb6db25c5a - Sigstore transparency entry: 1534614847
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datalogic_py-5.0.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: datalogic_py-5.0.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b568260e3acf41337d7187c1e2676c91fa65bd2ebdd9b8bbf7c9db37b4162bb
|
|
| MD5 |
86849aecd7f5ed6b84fc252b39c3d772
|
|
| BLAKE2b-256 |
c74e027fd289a9a4f29f8db65a87bb3848a1ff4780f1e10ea608a50677706e20
|
Provenance
The following attestation bundles were made for datalogic_py-5.0.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on GoPlasmatic/datalogic-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datalogic_py-5.0.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
5b568260e3acf41337d7187c1e2676c91fa65bd2ebdd9b8bbf7c9db37b4162bb - Sigstore transparency entry: 1534614342
- Sigstore integration time:
-
Permalink:
GoPlasmatic/datalogic-rs@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/GoPlasmatic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@821835abc46de920a958c7582e5f0ecc95ed90e8 -
Trigger Event:
push
-
Statement type: