ddi2sdmx-core 0.0.1__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.
@@ -0,0 +1,246 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "ddi2sdmx-core"
7
+ version = "0.0.1"
8
+ dependencies = [
9
+ "indexmap",
10
+ "memchr",
11
+ "pyo3",
12
+ "quick-xml",
13
+ "serde",
14
+ "serde_json",
15
+ "simdutf8",
16
+ ]
17
+
18
+ [[package]]
19
+ name = "equivalent"
20
+ version = "1.0.3"
21
+ source = "registry+https://github.com/rust-lang/crates.io-index"
22
+ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
23
+
24
+ [[package]]
25
+ name = "foldhash"
26
+ version = "0.2.0"
27
+ source = "registry+https://github.com/rust-lang/crates.io-index"
28
+ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
29
+
30
+ [[package]]
31
+ name = "hashbrown"
32
+ version = "0.17.1"
33
+ source = "registry+https://github.com/rust-lang/crates.io-index"
34
+ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
35
+
36
+ [[package]]
37
+ name = "heck"
38
+ version = "0.5.0"
39
+ source = "registry+https://github.com/rust-lang/crates.io-index"
40
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
41
+
42
+ [[package]]
43
+ name = "indexmap"
44
+ version = "2.14.2"
45
+ source = "registry+https://github.com/rust-lang/crates.io-index"
46
+ checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
47
+ dependencies = [
48
+ "equivalent",
49
+ "hashbrown",
50
+ "serde",
51
+ "serde_core",
52
+ ]
53
+
54
+ [[package]]
55
+ name = "itoa"
56
+ version = "1.0.18"
57
+ source = "registry+https://github.com/rust-lang/crates.io-index"
58
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
59
+
60
+ [[package]]
61
+ name = "libc"
62
+ version = "0.2.191"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
65
+
66
+ [[package]]
67
+ name = "memchr"
68
+ version = "2.8.3"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
71
+
72
+ [[package]]
73
+ name = "once_cell"
74
+ version = "1.21.4"
75
+ source = "registry+https://github.com/rust-lang/crates.io-index"
76
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
77
+
78
+ [[package]]
79
+ name = "portable-atomic"
80
+ version = "1.15.0"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
83
+
84
+ [[package]]
85
+ name = "proc-macro2"
86
+ version = "1.0.107"
87
+ source = "registry+https://github.com/rust-lang/crates.io-index"
88
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
89
+ dependencies = [
90
+ "unicode-ident",
91
+ ]
92
+
93
+ [[package]]
94
+ name = "pyo3"
95
+ version = "0.30.1"
96
+ source = "registry+https://github.com/rust-lang/crates.io-index"
97
+ checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
98
+ dependencies = [
99
+ "libc",
100
+ "once_cell",
101
+ "portable-atomic",
102
+ "pyo3-build-config",
103
+ "pyo3-ffi",
104
+ "pyo3-macros",
105
+ ]
106
+
107
+ [[package]]
108
+ name = "pyo3-build-config"
109
+ version = "0.30.1"
110
+ source = "registry+https://github.com/rust-lang/crates.io-index"
111
+ checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
112
+ dependencies = [
113
+ "target-lexicon",
114
+ ]
115
+
116
+ [[package]]
117
+ name = "pyo3-ffi"
118
+ version = "0.30.1"
119
+ source = "registry+https://github.com/rust-lang/crates.io-index"
120
+ checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
121
+ dependencies = [
122
+ "libc",
123
+ "pyo3-build-config",
124
+ ]
125
+
126
+ [[package]]
127
+ name = "pyo3-macros"
128
+ version = "0.30.1"
129
+ source = "registry+https://github.com/rust-lang/crates.io-index"
130
+ checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
131
+ dependencies = [
132
+ "proc-macro2",
133
+ "pyo3-macros-backend",
134
+ "quote",
135
+ "syn",
136
+ ]
137
+
138
+ [[package]]
139
+ name = "pyo3-macros-backend"
140
+ version = "0.30.1"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
143
+ dependencies = [
144
+ "heck",
145
+ "proc-macro2",
146
+ "quote",
147
+ "syn",
148
+ ]
149
+
150
+ [[package]]
151
+ name = "quick-xml"
152
+ version = "0.42.0"
153
+ source = "registry+https://github.com/rust-lang/crates.io-index"
154
+ checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b"
155
+ dependencies = [
156
+ "memchr",
157
+ ]
158
+
159
+ [[package]]
160
+ name = "quote"
161
+ version = "1.0.47"
162
+ source = "registry+https://github.com/rust-lang/crates.io-index"
163
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
164
+ dependencies = [
165
+ "proc-macro2",
166
+ ]
167
+
168
+ [[package]]
169
+ name = "serde"
170
+ version = "1.0.229"
171
+ source = "registry+https://github.com/rust-lang/crates.io-index"
172
+ checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
173
+ dependencies = [
174
+ "serde_core",
175
+ "serde_derive",
176
+ ]
177
+
178
+ [[package]]
179
+ name = "serde_core"
180
+ version = "1.0.229"
181
+ source = "registry+https://github.com/rust-lang/crates.io-index"
182
+ checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
183
+ dependencies = [
184
+ "serde_derive",
185
+ ]
186
+
187
+ [[package]]
188
+ name = "serde_derive"
189
+ version = "1.0.229"
190
+ source = "registry+https://github.com/rust-lang/crates.io-index"
191
+ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
192
+ dependencies = [
193
+ "proc-macro2",
194
+ "quote",
195
+ "syn",
196
+ ]
197
+
198
+ [[package]]
199
+ name = "serde_json"
200
+ version = "1.0.154"
201
+ source = "registry+https://github.com/rust-lang/crates.io-index"
202
+ checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
203
+ dependencies = [
204
+ "foldhash",
205
+ "indexmap",
206
+ "itoa",
207
+ "memchr",
208
+ "serde",
209
+ "serde_core",
210
+ "zmij",
211
+ ]
212
+
213
+ [[package]]
214
+ name = "simdutf8"
215
+ version = "0.1.5"
216
+ source = "registry+https://github.com/rust-lang/crates.io-index"
217
+ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
218
+
219
+ [[package]]
220
+ name = "syn"
221
+ version = "3.0.9"
222
+ source = "registry+https://github.com/rust-lang/crates.io-index"
223
+ checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
224
+ dependencies = [
225
+ "proc-macro2",
226
+ "quote",
227
+ "unicode-ident",
228
+ ]
229
+
230
+ [[package]]
231
+ name = "target-lexicon"
232
+ version = "0.13.5"
233
+ source = "registry+https://github.com/rust-lang/crates.io-index"
234
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
235
+
236
+ [[package]]
237
+ name = "unicode-ident"
238
+ version = "1.0.27"
239
+ source = "registry+https://github.com/rust-lang/crates.io-index"
240
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
241
+
242
+ [[package]]
243
+ name = "zmij"
244
+ version = "1.0.23"
245
+ source = "registry+https://github.com/rust-lang/crates.io-index"
246
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
@@ -0,0 +1,35 @@
1
+ [package]
2
+ name = "ddi2sdmx-core"
3
+ version = "0.0.1"
4
+ edition = "2021"
5
+ rust-version = "1.85"
6
+ description = "Fast DDI-Lifecycle reader for ddi2sdmx"
7
+ license = "MIT"
8
+ repository = "https://github.com/pbisson44/ddi2sdmx"
9
+ publish = false
10
+ readme = "README.md"
11
+
12
+ [lib]
13
+ name = "ddi2sdmx_core"
14
+ crate-type = ["cdylib", "rlib"]
15
+
16
+ [features]
17
+ default = []
18
+ # The Python extension module.
19
+ python = ["dep:pyo3"]
20
+ # One wheel for every CPython from 3.11 (maturin turns this on). Leave it
21
+ # out to build for a free-threaded Python, which abi3 does not cover.
22
+ abi3 = ["python", "pyo3/abi3-py311"]
23
+
24
+ [dependencies]
25
+ indexmap = { version = "2.14", features = ["serde"] }
26
+ memchr = "2.8"
27
+ pyo3 = { version = "0.30", optional = true }
28
+ quick-xml = "0.42"
29
+ serde = { version = "1.0", features = ["derive"] }
30
+ serde_json = { version = "1.0", features = ["preserve_order"] }
31
+ simdutf8 = "0.1"
32
+
33
+ [profile.release]
34
+ lto = true
35
+ codegen-units = 1
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pbisson44
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,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: ddi2sdmx-core
3
+ Version: 0.0.1
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: Implementation :: CPython
8
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
9
+ Classifier: Typing :: Typed
10
+ License-File: LICENSE
11
+ Summary: Fast DDI-Lifecycle reader for ddi2sdmx (Rust)
12
+ Author-email: pbisson44 <pbisson44@users.noreply.github.com>
13
+ License-Expression: MIT
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
16
+ Project-URL: Homepage, https://github.com/pbisson44/ddi2sdmx
17
+
18
+ # ddi2sdmx-core
19
+
20
+ The fast DDI-Lifecycle reader for [ddi2sdmx](https://github.com/pbisson44/ddi2sdmx),
21
+ in Rust. Install it with `pip install 'ddi2sdmx[fast]'`; `ddi2sdmx` uses it when
22
+ it is there and falls back to its pure-Python reader otherwise. Both give the
23
+ same document, which the test suite checks on every fixture and on random files.
24
+
25
+ ---
26
+
27
+ Le lecteur DDI-Lifecycle rapide de ddi2sdmx, en Rust. Installez-le avec
28
+ `pip install 'ddi2sdmx[fast]'` ; `ddi2sdmx` l'utilise s'il est présent et revient
29
+ sinon à son lecteur en Python pur. Les deux donnent le même document.
30
+
@@ -0,0 +1,12 @@
1
+ # ddi2sdmx-core
2
+
3
+ The fast DDI-Lifecycle reader for [ddi2sdmx](https://github.com/pbisson44/ddi2sdmx),
4
+ in Rust. Install it with `pip install 'ddi2sdmx[fast]'`; `ddi2sdmx` uses it when
5
+ it is there and falls back to its pure-Python reader otherwise. Both give the
6
+ same document, which the test suite checks on every fixture and on random files.
7
+
8
+ ---
9
+
10
+ Le lecteur DDI-Lifecycle rapide de ddi2sdmx, en Rust. Installez-le avec
11
+ `pip install 'ddi2sdmx[fast]'` ; `ddi2sdmx` l'utilise s'il est présent et revient
12
+ sinon à son lecteur en Python pur. Les deux donnent le même document.
@@ -0,0 +1,17 @@
1
+ """Fast DDI-Lifecycle reader for ddi2sdmx (Rust)."""
2
+
3
+ __version__: str
4
+
5
+ class Fallback(Exception): # noqa: N818 - the name says what to do
6
+ """Read this file with lxml instead."""
7
+
8
+ class TooManyObjects(Exception): # noqa: N818
9
+ """The file has more DDI objects than ``max_objects``."""
10
+
11
+ def parse_lifecycle(
12
+ data: bytes, ns: dict[str, str], lang: str | None, max_objects: int
13
+ ) -> bytes:
14
+ """Read a DDI-L file's bytes; return the document as JSON."""
15
+
16
+ def element_ranges(data: bytes) -> list[tuple[str, int, int]]:
17
+ """Byte ranges ``(id, start, end)`` of the identified elements."""
@@ -0,0 +1,53 @@
1
+ //! `cargo run --release --example bench -- FILE`: time one read.
2
+ use std::collections::HashMap;
3
+ use std::time::Instant;
4
+
5
+ use ddi2sdmx_core::ddi::{parse_lifecycle, Ns};
6
+
7
+ fn main() {
8
+ let path = std::env::args().nth(1).expect("FILE");
9
+ let data = std::fs::read(&path).expect("readable file");
10
+ let map: HashMap<String, String> = [
11
+ ("r", "ddi:reusable:3_3"),
12
+ ("lp", "ddi:logicalproduct:3_3"),
13
+ ("pi", "ddi:physicalinstance:3_3"),
14
+ ("dc", "ddi:datacollection:3_3"),
15
+ ("cc", "ddi:conceptualcomponent:3_3"),
16
+ ("inst", "ddi:instance:3_3"),
17
+ ]
18
+ .into_iter()
19
+ .map(|(k, v)| (k.to_string(), v.to_string()))
20
+ .collect();
21
+ let ns = Ns::from_map(&map).expect("namespaces");
22
+ let start = Instant::now();
23
+ let types = [
24
+ "Variable",
25
+ "CodeList",
26
+ "CodeScheme",
27
+ "Category",
28
+ "Concept",
29
+ "QuestionItem",
30
+ "PhysicalInstance",
31
+ "DataRelationship",
32
+ ];
33
+ let mut count = 0usize;
34
+ ddi2sdmx_core::xml::scan(&data, &ns.all, &types, &ns.r, u64::MAX, |node, _| {
35
+ count += node.children().count()
36
+ })
37
+ .expect("scan");
38
+ println!(
39
+ "trees only: {:.3} s ({count})",
40
+ start.elapsed().as_secs_f64()
41
+ );
42
+ let start = Instant::now();
43
+ let doc = parse_lifecycle(&data, &ns, Some("en"), u64::MAX).expect("parsed");
44
+ let parsed = start.elapsed().as_secs_f64();
45
+ let json = serde_json::to_vec(&doc).expect("json");
46
+ println!("parse {parsed:.3} s");
47
+ println!(
48
+ "{} variables, {} JSON bytes in {:.3} s",
49
+ doc.variables.len(),
50
+ json.len(),
51
+ start.elapsed().as_secs_f64()
52
+ );
53
+ }
@@ -0,0 +1,32 @@
1
+ //! How fast quick-xml alone reads a file (no tree, no checks).
2
+ use std::time::Instant;
3
+ fn main() {
4
+ let path = std::env::args().nth(1).expect("FILE");
5
+ let data = std::fs::read_to_string(&path).expect("UTF-8 file");
6
+ for ns in [false, true] {
7
+ let start = Instant::now();
8
+ let mut n = 0u64;
9
+ if ns {
10
+ let mut r = quick_xml::reader::NsReader::from_str(&data);
11
+ r.config_mut().expand_empty_elements = true;
12
+ while !matches!(
13
+ r.read_resolved_event().expect("xml").1,
14
+ quick_xml::events::Event::Eof
15
+ ) {
16
+ n += 1;
17
+ }
18
+ } else {
19
+ let mut r = quick_xml::reader::Reader::from_str(&data);
20
+ while !matches!(r.read_event().expect("xml"), quick_xml::events::Event::Eof) {
21
+ n += 1;
22
+ }
23
+ }
24
+ println!(
25
+ "ns={ns}: {n} events in {:.3} s",
26
+ start.elapsed().as_secs_f64()
27
+ );
28
+ }
29
+ let start = Instant::now();
30
+ let ok = simdutf8::basic::from_utf8(data.as_bytes()).is_ok();
31
+ println!("utf8 check {ok} in {:.3} s", start.elapsed().as_secs_f64());
32
+ }
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.15,<2"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "ddi2sdmx-core"
7
+ version = "0.0.1"
8
+ description = "Fast DDI-Lifecycle reader for ddi2sdmx (Rust)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ authors = [{ name = "pbisson44", email = "pbisson44@users.noreply.github.com" }]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Programming Language :: Rust",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: Implementation :: CPython",
18
+ "Topic :: Scientific/Engineering :: Information Analysis",
19
+ "Typing :: Typed",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/pbisson44/ddi2sdmx"
24
+
25
+ [tool.maturin]
26
+ features = ["abi3"]
27
+ module-name = "ddi2sdmx_core"
28
+
29
+ # Rebuild the extension when its Rust sources change, so `uv sync` (and the
30
+ # gate) never tests a stale build.
31
+ [tool.uv]
32
+ cache-keys = [
33
+ { file = "pyproject.toml" },
34
+ { file = "Cargo.toml" },
35
+ { file = "Cargo.lock" },
36
+ { file = "src/**/*.rs" },
37
+ ]