jmespath-rs 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jmespath_rs-0.1.0/.github/workflows/ci.yml +50 -0
- jmespath_rs-0.1.0/.github/workflows/wheels.yml +161 -0
- jmespath_rs-0.1.0/.gitignore +14 -0
- jmespath_rs-0.1.0/Cargo.lock +224 -0
- jmespath_rs-0.1.0/Cargo.toml +31 -0
- jmespath_rs-0.1.0/LICENSE +21 -0
- jmespath_rs-0.1.0/PKG-INFO +173 -0
- jmespath_rs-0.1.0/README.md +146 -0
- jmespath_rs-0.1.0/benchmarks/bench.py +254 -0
- jmespath_rs-0.1.0/pyproject.toml +47 -0
- jmespath_rs-0.1.0/python/jmespath_rs/__init__.py +105 -0
- jmespath_rs-0.1.0/python/jmespath_rs/ast.py +86 -0
- jmespath_rs-0.1.0/python/jmespath_rs/compat.py +27 -0
- jmespath_rs-0.1.0/python/jmespath_rs/exceptions.py +116 -0
- jmespath_rs-0.1.0/python/jmespath_rs/functions.py +319 -0
- jmespath_rs-0.1.0/python/jmespath_rs/lexer.py +8 -0
- jmespath_rs-0.1.0/python/jmespath_rs/parser.py +20 -0
- jmespath_rs-0.1.0/python/jmespath_rs/py.typed +0 -0
- jmespath_rs-0.1.0/python/jmespath_rs/visitor.py +272 -0
- jmespath_rs-0.1.0/scripts/attribution-guard.sh +45 -0
- jmespath_rs-0.1.0/src/ast.rs +364 -0
- jmespath_rs-0.1.0/src/error.rs +262 -0
- jmespath_rs-0.1.0/src/eval.rs +756 -0
- jmespath_rs-0.1.0/src/functions.rs +934 -0
- jmespath_rs-0.1.0/src/json_eval.rs +1456 -0
- jmespath_rs-0.1.0/src/lexer.rs +518 -0
- jmespath_rs-0.1.0/src/lib.rs +371 -0
- jmespath_rs-0.1.0/src/parser.rs +580 -0
- jmespath_rs-0.1.0/tests/__init__.py +5 -0
- jmespath_rs-0.1.0/tests/conftest.py +49 -0
- jmespath_rs-0.1.0/tests/test_jmespath_rs.py +262 -0
- jmespath_rs-0.1.0/tests/upstream/__init__.py +31 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/basic.json +96 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/benchmarks.json +148 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/boolean.json +288 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/current.json +25 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/escape.json +46 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/filters.json +594 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/functions.json +841 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/identifiers.json +1377 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/indices.json +346 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/literal.json +200 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/multiselect.json +398 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/pipe.json +131 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/slice.json +187 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/syntax.json +692 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/unicode.json +38 -0
- jmespath_rs-0.1.0/tests/upstream/compliance/wildcard.json +460 -0
- jmespath_rs-0.1.0/tests/upstream/legacy/literal.json +56 -0
- jmespath_rs-0.1.0/tests/upstream/test_compliance.py +118 -0
- jmespath_rs-0.1.0/tests/upstream/test_custom_functions.py +25 -0
- jmespath_rs-0.1.0/tests/upstream/test_functions.py +57 -0
- jmespath_rs-0.1.0/tests/upstream/test_lexer.py +160 -0
- jmespath_rs-0.1.0/tests/upstream/test_parser.py +394 -0
- jmespath_rs-0.1.0/tests/upstream/test_search.py +64 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
rust:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
17
|
+
with:
|
|
18
|
+
components: rustfmt, clippy
|
|
19
|
+
- uses: Swatinem/rust-cache@v2
|
|
20
|
+
- run: cargo fmt --check
|
|
21
|
+
- run: cargo clippy --all-targets -- -D warnings
|
|
22
|
+
- run: cargo test
|
|
23
|
+
|
|
24
|
+
python:
|
|
25
|
+
strategy:
|
|
26
|
+
fail-fast: false
|
|
27
|
+
matrix:
|
|
28
|
+
os: [ubuntu-24.04, macos-latest, windows-latest]
|
|
29
|
+
python-version: ["3.9", "3.11", "3.13"]
|
|
30
|
+
runs-on: ${{ matrix.os }}
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: ${{ matrix.python-version }}
|
|
36
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
37
|
+
- uses: Swatinem/rust-cache@v2
|
|
38
|
+
- run: python -m pip install --upgrade pip maturin pytest ruff jmespath
|
|
39
|
+
- run: ruff check python tests benchmarks
|
|
40
|
+
- run: maturin build --release --out dist
|
|
41
|
+
- run: python -m pip install --no-index --find-links dist jmespath-rs
|
|
42
|
+
- run: python -m pytest
|
|
43
|
+
|
|
44
|
+
guard:
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v4
|
|
48
|
+
with:
|
|
49
|
+
fetch-depth: 0
|
|
50
|
+
- run: bash scripts/attribution-guard.sh files
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
name: Wheels & Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
linux:
|
|
14
|
+
runs-on: ${{ matrix.runner }}
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
include:
|
|
19
|
+
- target: x86_64
|
|
20
|
+
runner: ubuntu-24.04
|
|
21
|
+
manylinux: auto
|
|
22
|
+
- target: aarch64
|
|
23
|
+
runner: ubuntu-24.04-arm
|
|
24
|
+
manylinux: auto
|
|
25
|
+
- target: x86_64
|
|
26
|
+
runner: ubuntu-24.04
|
|
27
|
+
manylinux: musllinux_1_2
|
|
28
|
+
- target: aarch64
|
|
29
|
+
runner: ubuntu-24.04-arm
|
|
30
|
+
manylinux: musllinux_1_2
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- uses: PyO3/maturin-action@v1
|
|
37
|
+
with:
|
|
38
|
+
target: ${{ matrix.target }}
|
|
39
|
+
args: --release --out dist --find-interpreter
|
|
40
|
+
sccache: "true"
|
|
41
|
+
manylinux: ${{ matrix.manylinux }}
|
|
42
|
+
- name: Test manylinux wheel
|
|
43
|
+
if: matrix.manylinux == 'auto'
|
|
44
|
+
run: |
|
|
45
|
+
python -m pip install --upgrade pip pytest jmespath
|
|
46
|
+
python -m pip install --no-index --find-links dist jmespath-rs
|
|
47
|
+
python -m pytest
|
|
48
|
+
python -c "import jmespath_rs as jp; assert jp.search('foo.bar[0]', {'foo': {'bar': [42]}}) == 42"
|
|
49
|
+
- name: Test musllinux wheel
|
|
50
|
+
if: matrix.manylinux == 'musllinux_1_2'
|
|
51
|
+
run: |
|
|
52
|
+
docker run --rm -v "${{ github.workspace }}:/work" -w /work python:3.12-alpine sh -c '
|
|
53
|
+
python -m pip install --no-cache-dir pytest jmespath &&
|
|
54
|
+
python -m pip install --no-index --find-links dist jmespath-rs &&
|
|
55
|
+
python -m pytest &&
|
|
56
|
+
python -c "import jmespath_rs as jp; assert jp.search(\"foo.bar[0]\", {\"foo\": {\"bar\": [42]}}) == 42"
|
|
57
|
+
'
|
|
58
|
+
- uses: actions/upload-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
name: wheels-linux-${{ matrix.manylinux }}-${{ matrix.target }}
|
|
61
|
+
path: dist
|
|
62
|
+
|
|
63
|
+
macos:
|
|
64
|
+
runs-on: ${{ matrix.runner }}
|
|
65
|
+
strategy:
|
|
66
|
+
fail-fast: false
|
|
67
|
+
matrix:
|
|
68
|
+
include:
|
|
69
|
+
- runner: macos-15
|
|
70
|
+
target: aarch64-apple-darwin
|
|
71
|
+
- runner: macos-15-intel
|
|
72
|
+
target: x86_64-apple-darwin
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/checkout@v4
|
|
75
|
+
- uses: actions/setup-python@v5
|
|
76
|
+
with:
|
|
77
|
+
python-version: "3.12"
|
|
78
|
+
- uses: PyO3/maturin-action@v1
|
|
79
|
+
with:
|
|
80
|
+
target: ${{ matrix.target }}
|
|
81
|
+
args: --release --out dist --find-interpreter
|
|
82
|
+
sccache: "true"
|
|
83
|
+
- name: Test macOS wheel
|
|
84
|
+
run: |
|
|
85
|
+
python -m pip install --upgrade pip pytest jmespath
|
|
86
|
+
python -m pip install --no-index --find-links dist jmespath-rs
|
|
87
|
+
python -m pytest
|
|
88
|
+
python -c "import jmespath_rs as jp; assert jp.search('foo.bar[0]', {'foo': {'bar': [42]}}) == 42"
|
|
89
|
+
- uses: actions/upload-artifact@v4
|
|
90
|
+
with:
|
|
91
|
+
name: wheels-macos-${{ matrix.target }}
|
|
92
|
+
path: dist
|
|
93
|
+
|
|
94
|
+
windows:
|
|
95
|
+
runs-on: windows-latest
|
|
96
|
+
strategy:
|
|
97
|
+
fail-fast: false
|
|
98
|
+
matrix:
|
|
99
|
+
target: [x64]
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@v4
|
|
102
|
+
- uses: actions/setup-python@v5
|
|
103
|
+
with:
|
|
104
|
+
python-version: "3.12"
|
|
105
|
+
- uses: PyO3/maturin-action@v1
|
|
106
|
+
with:
|
|
107
|
+
target: ${{ matrix.target }}
|
|
108
|
+
args: --release --out dist --find-interpreter
|
|
109
|
+
sccache: "true"
|
|
110
|
+
- name: Test Windows wheel
|
|
111
|
+
shell: bash
|
|
112
|
+
run: |
|
|
113
|
+
python -m pip install --upgrade pip pytest jmespath
|
|
114
|
+
python -m pip install --no-index --find-links dist jmespath-rs
|
|
115
|
+
python -m pytest
|
|
116
|
+
python -c "import jmespath_rs as jp; assert jp.search('foo.bar[0]', {'foo': {'bar': [42]}}) == 42"
|
|
117
|
+
- uses: actions/upload-artifact@v4
|
|
118
|
+
with:
|
|
119
|
+
name: wheels-windows-${{ matrix.target }}
|
|
120
|
+
path: dist
|
|
121
|
+
|
|
122
|
+
sdist:
|
|
123
|
+
runs-on: ubuntu-24.04
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- uses: actions/setup-python@v5
|
|
127
|
+
with:
|
|
128
|
+
python-version: "3.12"
|
|
129
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
130
|
+
- uses: PyO3/maturin-action@v1
|
|
131
|
+
with:
|
|
132
|
+
command: sdist
|
|
133
|
+
args: --out dist
|
|
134
|
+
- name: Verify sdist metadata and source install
|
|
135
|
+
run: |
|
|
136
|
+
python -m pip install --upgrade pip twine pytest maturin jmespath
|
|
137
|
+
twine check dist/*
|
|
138
|
+
python -m pip install --no-build-isolation dist/*.tar.gz
|
|
139
|
+
python -m pytest
|
|
140
|
+
- uses: actions/upload-artifact@v4
|
|
141
|
+
with:
|
|
142
|
+
name: wheels-sdist
|
|
143
|
+
path: dist
|
|
144
|
+
|
|
145
|
+
release:
|
|
146
|
+
name: Publish to PyPI
|
|
147
|
+
runs-on: ubuntu-24.04
|
|
148
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
149
|
+
needs: [linux, macos, windows, sdist]
|
|
150
|
+
environment: pypi
|
|
151
|
+
permissions:
|
|
152
|
+
id-token: write
|
|
153
|
+
steps:
|
|
154
|
+
- uses: actions/download-artifact@v4
|
|
155
|
+
with:
|
|
156
|
+
pattern: wheels-*
|
|
157
|
+
merge-multiple: true
|
|
158
|
+
path: dist
|
|
159
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
160
|
+
with:
|
|
161
|
+
packages-dir: dist/
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "equivalent"
|
|
7
|
+
version = "1.0.3"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "foldhash"
|
|
13
|
+
version = "0.2.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "hashbrown"
|
|
19
|
+
version = "0.17.2"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "heck"
|
|
25
|
+
version = "0.5.0"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "indexmap"
|
|
31
|
+
version = "2.14.2"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
|
34
|
+
dependencies = [
|
|
35
|
+
"equivalent",
|
|
36
|
+
"hashbrown",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[[package]]
|
|
40
|
+
name = "itoa"
|
|
41
|
+
version = "1.0.19"
|
|
42
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
43
|
+
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "jmespath-rs"
|
|
47
|
+
version = "0.1.0"
|
|
48
|
+
dependencies = [
|
|
49
|
+
"pyo3",
|
|
50
|
+
"serde",
|
|
51
|
+
"serde_json",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[[package]]
|
|
55
|
+
name = "libc"
|
|
56
|
+
version = "0.2.191"
|
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
58
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "memchr"
|
|
62
|
+
version = "2.8.3"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
65
|
+
|
|
66
|
+
[[package]]
|
|
67
|
+
name = "once_cell"
|
|
68
|
+
version = "1.21.4"
|
|
69
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
70
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
71
|
+
|
|
72
|
+
[[package]]
|
|
73
|
+
name = "portable-atomic"
|
|
74
|
+
version = "1.15.0"
|
|
75
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
76
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
77
|
+
|
|
78
|
+
[[package]]
|
|
79
|
+
name = "proc-macro2"
|
|
80
|
+
version = "1.0.107"
|
|
81
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
82
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
83
|
+
dependencies = [
|
|
84
|
+
"unicode-ident",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
[[package]]
|
|
88
|
+
name = "pyo3"
|
|
89
|
+
version = "0.30.1"
|
|
90
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
91
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
92
|
+
dependencies = [
|
|
93
|
+
"libc",
|
|
94
|
+
"once_cell",
|
|
95
|
+
"portable-atomic",
|
|
96
|
+
"pyo3-build-config",
|
|
97
|
+
"pyo3-ffi",
|
|
98
|
+
"pyo3-macros",
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
[[package]]
|
|
102
|
+
name = "pyo3-build-config"
|
|
103
|
+
version = "0.30.1"
|
|
104
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
105
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
106
|
+
dependencies = [
|
|
107
|
+
"target-lexicon",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
[[package]]
|
|
111
|
+
name = "pyo3-ffi"
|
|
112
|
+
version = "0.30.1"
|
|
113
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
114
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
115
|
+
dependencies = [
|
|
116
|
+
"libc",
|
|
117
|
+
"pyo3-build-config",
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
[[package]]
|
|
121
|
+
name = "pyo3-macros"
|
|
122
|
+
version = "0.30.1"
|
|
123
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
124
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
125
|
+
dependencies = [
|
|
126
|
+
"proc-macro2",
|
|
127
|
+
"pyo3-macros-backend",
|
|
128
|
+
"quote",
|
|
129
|
+
"syn",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
[[package]]
|
|
133
|
+
name = "pyo3-macros-backend"
|
|
134
|
+
version = "0.30.1"
|
|
135
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
136
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
137
|
+
dependencies = [
|
|
138
|
+
"heck",
|
|
139
|
+
"proc-macro2",
|
|
140
|
+
"quote",
|
|
141
|
+
"syn",
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
[[package]]
|
|
145
|
+
name = "quote"
|
|
146
|
+
version = "1.0.47"
|
|
147
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
148
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
149
|
+
dependencies = [
|
|
150
|
+
"proc-macro2",
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
[[package]]
|
|
154
|
+
name = "serde"
|
|
155
|
+
version = "1.0.229"
|
|
156
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
157
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
158
|
+
dependencies = [
|
|
159
|
+
"serde_core",
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
[[package]]
|
|
163
|
+
name = "serde_core"
|
|
164
|
+
version = "1.0.229"
|
|
165
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
166
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
167
|
+
dependencies = [
|
|
168
|
+
"serde_derive",
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
[[package]]
|
|
172
|
+
name = "serde_derive"
|
|
173
|
+
version = "1.0.229"
|
|
174
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
175
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
176
|
+
dependencies = [
|
|
177
|
+
"proc-macro2",
|
|
178
|
+
"quote",
|
|
179
|
+
"syn",
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
[[package]]
|
|
183
|
+
name = "serde_json"
|
|
184
|
+
version = "1.0.154"
|
|
185
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
186
|
+
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
|
187
|
+
dependencies = [
|
|
188
|
+
"foldhash",
|
|
189
|
+
"indexmap",
|
|
190
|
+
"itoa",
|
|
191
|
+
"memchr",
|
|
192
|
+
"serde",
|
|
193
|
+
"serde_core",
|
|
194
|
+
"zmij",
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
[[package]]
|
|
198
|
+
name = "syn"
|
|
199
|
+
version = "3.0.10"
|
|
200
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
201
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
202
|
+
dependencies = [
|
|
203
|
+
"proc-macro2",
|
|
204
|
+
"quote",
|
|
205
|
+
"unicode-ident",
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
[[package]]
|
|
209
|
+
name = "target-lexicon"
|
|
210
|
+
version = "0.13.6"
|
|
211
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
212
|
+
checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
|
|
213
|
+
|
|
214
|
+
[[package]]
|
|
215
|
+
name = "unicode-ident"
|
|
216
|
+
version = "1.0.27"
|
|
217
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
218
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
219
|
+
|
|
220
|
+
[[package]]
|
|
221
|
+
name = "zmij"
|
|
222
|
+
version = "1.0.23"
|
|
223
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
224
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "jmespath-rs"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
rust-version = "1.85"
|
|
6
|
+
description = "Fast, safe, drop-in Rust replacement for Python's jmespath with direct PyO3 evaluation and zero reference cycles"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
repository = "https://github.com/brixtonpham/jmespath-rs"
|
|
10
|
+
keywords = ["jmespath", "json", "query", "pyo3", "python"]
|
|
11
|
+
categories = ["parsing", "encoding"]
|
|
12
|
+
|
|
13
|
+
[lib]
|
|
14
|
+
name = "jmespath_rs"
|
|
15
|
+
crate-type = ["cdylib", "rlib"]
|
|
16
|
+
|
|
17
|
+
[dependencies]
|
|
18
|
+
pyo3 = { version = "0.30", optional = true, features = ["abi3-py39"] }
|
|
19
|
+
serde = "1"
|
|
20
|
+
serde_json = { version = "1", features = ["preserve_order"] }
|
|
21
|
+
|
|
22
|
+
[features]
|
|
23
|
+
default = []
|
|
24
|
+
python = ["dep:pyo3"]
|
|
25
|
+
extension-module = ["python", "pyo3/extension-module"]
|
|
26
|
+
|
|
27
|
+
[profile.release]
|
|
28
|
+
lto = "fat"
|
|
29
|
+
codegen-units = 1
|
|
30
|
+
opt-level = 3
|
|
31
|
+
strip = "symbols"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brixton Pham
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jmespath-rs
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Programming Language :: Rust
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Summary: Fast, safe, drop-in Rust replacement for jmespath with direct PyO3 traversal and raw JSON search
|
|
18
|
+
Keywords: jmespath,json,query,aws,boto3,rust,pyo3
|
|
19
|
+
Author-email: Brixton Pham <117471232+brixtonpham@users.noreply.github.com>
|
|
20
|
+
License: MIT
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
23
|
+
Project-URL: Homepage, https://github.com/brixtonpham/jmespath-rs
|
|
24
|
+
Project-URL: Issues, https://github.com/brixtonpham/jmespath-rs/issues
|
|
25
|
+
Project-URL: Repository, https://github.com/brixtonpham/jmespath-rs
|
|
26
|
+
|
|
27
|
+
# jmespath-rs
|
|
28
|
+
|
|
29
|
+
[](https://github.com/brixtonpham/jmespath-rs/actions/workflows/ci.yml)
|
|
30
|
+
[](LICENSE)
|
|
31
|
+
|
|
32
|
+
Fast, memory-safe (`#![forbid(unsafe_code)]`), drop-in Rust replacement for Python's [`jmespath`](https://github.com/jmespath/jmespath.py).
|
|
33
|
+
|
|
34
|
+
- **100% specification compatible** — passes the complete upstream `jmespath.py` test suite and all official JMESPath compliance tests (991 upstream tests + 911 `search_json` compliance cases).
|
|
35
|
+
- **Direct PyO3 object traversal** — evaluates compiled Rust ASTs directly against Python `dict`, `list`, `tuple`, `Mapping`, and `Sequence` objects with **zero JSON re-serialization**.
|
|
36
|
+
- **Zero reference cycles** — eliminates the per-call cyclic garbage leak in `jmespath.py` (`gc.collect() == 0` after thousands of queries).
|
|
37
|
+
- **GIL-free raw JSON search (`search_json`)** — parses UTF-8 JSON bytes into a zero-copy borrowed DOM and evaluates the query in Rust with the GIL released, converting only the matched result into Python objects (up to **9× lower Python heap peak**).
|
|
38
|
+
- **One-line runtime patching** — `jmespath_rs.patch()` accelerates existing `boto3`, `botocore`, and `ansible` code without changing imports.
|
|
39
|
+
- **Full `Options` parity** — supports `Options(dict_cls=OrderedDict, custom_functions=...)` and all 26 built-in JMESPath functions.
|
|
40
|
+
- **Prebuilt `abi3-py39` wheels** — single stable-ABI wheel for Python 3.9–3.14 across Linux, macOS, and Windows.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install jmespath-rs
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
### Drop-in replacement
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import jmespath_rs as jmespath
|
|
54
|
+
|
|
55
|
+
data = {
|
|
56
|
+
"Reservations": [
|
|
57
|
+
{
|
|
58
|
+
"Instances": [
|
|
59
|
+
{"InstanceId": "i-01", "State": {"Name": "running"}},
|
|
60
|
+
{"InstanceId": "i-02", "State": {"Name": "stopped"}},
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
ids = jmespath.search(
|
|
67
|
+
"Reservations[].Instances[?State.Name == 'running'][].InstanceId",
|
|
68
|
+
data,
|
|
69
|
+
)
|
|
70
|
+
# ['i-01']
|
|
71
|
+
|
|
72
|
+
expr = jmespath.compile("Reservations[].Instances[].InstanceId")
|
|
73
|
+
all_ids = expr.search(data)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### One-line `boto3` / `botocore` patch
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import jmespath_rs
|
|
80
|
+
|
|
81
|
+
jmespath_rs.patch()
|
|
82
|
+
# All subsequent jmespath.search() and jmespath.compile() calls run in Rust.
|
|
83
|
+
|
|
84
|
+
# Restore upstream jmespath at any time:
|
|
85
|
+
jmespath_rs.unpatch()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Fast raw JSON search (GIL released)
|
|
89
|
+
|
|
90
|
+
When querying raw HTTP/API JSON payloads, skip `json.loads()` completely:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import jmespath_rs
|
|
94
|
+
|
|
95
|
+
raw_bytes = b'{"items": [{"name": "a", "active": true}, {"name": "b", "active": false}]}'
|
|
96
|
+
names = jmespath_rs.search_json("items[?active].name", raw_bytes)
|
|
97
|
+
# ['a']
|
|
98
|
+
|
|
99
|
+
# Precompiled expressions also support search_json():
|
|
100
|
+
compiled = jmespath_rs.compile("items[?active].name")
|
|
101
|
+
names = compiled.search_json(raw_bytes)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Custom functions and `dict_cls`
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from collections import OrderedDict
|
|
108
|
+
import jmespath_rs
|
|
109
|
+
from jmespath_rs import Options, functions
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class CustomFunctions(functions.Functions):
|
|
113
|
+
@functions.signature({"types": ["number"]}, {"types": ["number"]})
|
|
114
|
+
def _func_add(self, x, y):
|
|
115
|
+
return x + y
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
opts = Options(dict_cls=OrderedDict, custom_functions=CustomFunctions())
|
|
119
|
+
result = jmespath_rs.search("{sum: add(`2`, `3`), ok: `true`}", {}, options=opts)
|
|
120
|
+
# OrderedDict([('sum', 5), ('ok', True)])
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Benchmarks
|
|
124
|
+
|
|
125
|
+
Measured locally on Apple Silicon (CPython 3.12, `jmespath==1.1.0` vs `jmespath-rs==0.1.0`) using [`benchmarks/bench.py`](benchmarks/bench.py):
|
|
126
|
+
|
|
127
|
+
### In-memory Python object queries
|
|
128
|
+
|
|
129
|
+
| Workload | `jmespath.search` | `jmespath_rs.search` | Speedup | `compile().search` speedup |
|
|
130
|
+
|---|---:|---:|---:|---:|
|
|
131
|
+
| AWS EC2 `describe-instances` (600 instances) | 2,896 µs | 420 µs | **6.9×** | **6.4×** |
|
|
132
|
+
| AWS S3 `list-objects` (1,000 objects) | 3,120 µs | 315 µs | **9.9×** | **10.2×** |
|
|
133
|
+
| AWS IAM policies (300 × 4 statements) | 434 µs | 30.4 µs | **14.3×** | **15.5×** |
|
|
134
|
+
| Kubernetes `PodList` (500 pods) | 2,568 µs | 212 µs | **12.1×** | **7.9×** |
|
|
135
|
+
| Small API payload (hot lookup) | 5.6 µs | 0.7 µs | **8.3×** | **9.1×** |
|
|
136
|
+
|
|
137
|
+
### Raw JSON bytes (`json.loads` + `jmespath` vs `jmespath_rs.search_json`)
|
|
138
|
+
|
|
139
|
+
| Workload | Payload size | `json.loads` + `jmespath` | `jmespath_rs.search_json` | Speedup |
|
|
140
|
+
|---|---:|---:|---:|---:|
|
|
141
|
+
| AWS EC2 `describe-instances` (600) | 226.9 KiB | 3,375 µs | 936 µs | **3.6×** |
|
|
142
|
+
| AWS S3 `list-objects` (1,000) | 181.5 KiB | 3,243 µs | 463 µs | **7.0×** |
|
|
143
|
+
| AWS IAM policies (300 × 4) | 202.7 KiB | 1,839 µs | 626 µs | **2.9×** |
|
|
144
|
+
| Kubernetes `PodList` (500 pods) | 145.7 KiB | 3,157 µs | 773 µs | **4.1×** |
|
|
145
|
+
| Small API payload | 0.1 KiB | 6.6 µs | 0.9 µs | **7.4×** |
|
|
146
|
+
|
|
147
|
+
### Python heap peak (`tracemalloc`) & cyclic garbage (`gc.collect()`)
|
|
148
|
+
|
|
149
|
+
| Benchmark | `jmespath` 1.1.0 | `jmespath_rs` 0.1.0 | Improvement |
|
|
150
|
+
|---|---:|---:|---:|
|
|
151
|
+
| EC2 in-memory (50 runs) — peak heap | 167.4 KiB | 56.1 KiB | **3.0× lower** |
|
|
152
|
+
| EC2 in-memory (50 runs) — cyclic GC objects | 950 | **0** | **0 cycles** |
|
|
153
|
+
| EC2 raw JSON E2E (20 runs) — peak heap | 1,386.6 KiB | 153.1 KiB | **9.1× lower** |
|
|
154
|
+
| EC2 raw JSON E2E (20 runs) — cyclic GC objects | 380 | **0** | **0 cycles** |
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Format, lint, and test Rust core
|
|
160
|
+
cargo fmt --check
|
|
161
|
+
cargo clippy --all-targets -- -D warnings
|
|
162
|
+
cargo test
|
|
163
|
+
|
|
164
|
+
# Build release extension and run full Python test suite (upstream + dedicated)
|
|
165
|
+
maturin develop --release
|
|
166
|
+
pytest
|
|
167
|
+
ruff check python tests benchmarks
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT — see [LICENSE](LICENSE).
|
|
173
|
+
|