Jelq
A small pipeline language for NDJSON streams. Numbers are exact decimals (wei, IDs, prices),
and the stream is never buffered. It either gives the exact answer or stops and names the line.
Spec: SPEC.md. Interpreter: one file, jelq.py, standard library only (Python ≥ 3.11).
Coming from jq? See docs/jq-users.md. Worked examples: examples/.
pip install . # from a checkout; gives you the `jelq` command
jelq PROGRAM [FILE ...] # NDJSON in (files or stdin), NDJSON out
jelq -f program.jelq data.ndjson # program from a file
jelq --help # stages, builtins, number rules
# The example from the design brief
jelq '. |> filter(.amount > 1_000_000) |> map({id: .id, value: .amount}) |> acc $acc + .value with 0'
# Per-account wei totals; amounts given as hex or decimal strings, uint256-exact
jelq 'sum(int(.wei)) by .acct'
# Revenue per SKU from decimal prices: exact to the cent (others print 5001275192.630049)
jelq 'sum(.price * .qty) by .sku'
# Prices shipped as strings, an average rounded only where you say so
jelq 'map({sku: .sku, avg: div(num(.total), .count, 2)})'
# Progressive refinement: a running total after every record, as strings for JS consumers
tail -f ticks.ndjson | jelq 'filter(.side == "buy") |> scan $acc + .qty with 0 |> map(str(.))'
# Log lines about failed payouts, with exact millisecond timestamps
jelq 'filter(test(lower(.msg), "payout failed")) |> map({at: fromdate(.ts), msg: .msg})'
# take() terminates even on an infinite stream
yes '{"n":1}' | jelq 'scan $acc + .n with 0 |> take(3)'
Stages: filter, map, expand, take, acc, scan (plus sum, count, min and max,
which are shorthand for acc). Each of them, with or without by KEY grouping where it
applies, is defined in SPEC.md §4.
Numbers:
0.1 + 0.2is0.3,0.07 * 100is7.00, and13 / 4is3.25.1 / 3is an error, because it has no exact decimal form. Round explicitly withdiv(1, 3, 2)→0.33orround(x, 2), both half to even.- There is no digit cap: two 4-million-digit integers sum in 0.14 s (SPEC.md §1).
Strings and dates:
test,split,join,startswith,endswith,lower,upper.fromdateandtodateconvert ISO 8601 dates to and from exact seconds. Nanoseconds survive. A time with no timezone is an error, never a guess.
What it will not do: binary floats, implicit rounding, truthiness (filter(.x) needs a
boolean), sorting or anything else that needs the whole stream.
Tests
python3 tests/test_jelq.py # or: pytest tests/
There are 53 tests (a few seconds), in five groups:
- Exact integers: 2⁵³+1 round-trips byte for byte, every operator matches Python
inton random 300-digit numbers, million-digit inputs work, and uint256 and hex conversion are exact. - Exact decimals: every operator,
/anddiv()are checked againstfractions.Fractionon random decimals (up to 40 places, 90 digits). The money cases floats get wrong are covered, as are half-even rounding and the exponent-notation guard. - Streaming:
takepulls exactly what it needs from an infinite source, and the first output arrives before later input is read. Peak memory is flat from 5k to 50k records, with a negative control. The CLI emits output while stdin is still open. - Semantics: grouping, empty streams, strict typing, error line numbers, parse errors
with a caret, CLI options, string and date functions (dates checked against Python
datetimearithmetic), and the examples. - Fuzzing:
python3 tests/fuzz.py N SEEDgenerates random programs and records. The only error allowed is a clean Jelq error; output must never contain a float, must survive an encode/decode round trip, and must be deterministic. 100,000 programs over 4 seeds: 0 violations. A short run is part of the suite.
Comparison with jq, gojq, jaq
See bench/RESULTS.md. The short version:
- On 15 big-integer tasks, jq 1.8.2 is silently wrong on 10. gojq is exact on all 15, the same as Jelq.
- On 9 decimal-money tasks, Jelq is correct on all 9. Every other tool is correct on 1 and
prints a wrong amount on the other 8 (
0.9999999999999999,7.000000000000001,5001275192.630049). - At 1M records Jelq is about as fast as jq and gojq, and about 2× slower than jaq.
License
Licensed under either of Apache License, Version 2.0 or MIT license, at your option. Unless you explicitly state otherwise, any contribution you submit for inclusion in this project is dual licensed as above, without additional terms or conditions.
Metadata
Release files for jelq 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jelq-0.3.0.tar.gz | 32.2 kB | With provenance | Details for jelq-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jelq-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for jelq-0.3.0-py3-none-any.whl |
Total release size: 54.5 kB
Release files / jelq-0.3.0.tar.gz
| Download URL | jelq-0.3.0.tar.gz |
|---|---|
| Size | 32.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6f9b54b7dee7866bb630613a6c7f920a7ba95da78143349d6535560d5a22f1a
|
|
BLAKE2b-256 checksum How to use checksums |
ef144004a2910803ec2d0bf3cbeb4116d68c2a6bc04ad385c046c7c84e33a714
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / jelq-0.3.0-py3-none-any.whl
| Download URL | jelq-0.3.0-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8bb0a2b509021c7e62582655b6255c1d6eae67e0be2207f6552ce8f91df6ccc4
|
|
BLAKE2b-256 checksum How to use checksums |
88ae8892f5a89c9bc6464187b4863db8d9caec5ec8d35dc6330f04f2ad449c24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for jelq 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for jelq-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.