polyxml 0.2.1__tar.gz → 0.3.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.
Files changed (23) hide show
  1. {polyxml-0.2.1 → polyxml-0.3.0}/Cargo.lock +22 -43
  2. {polyxml-0.2.1 → polyxml-0.3.0}/Cargo.toml +1 -1
  3. {polyxml-0.2.1 → polyxml-0.3.0}/PKG-INFO +1 -1
  4. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/Cargo.toml +2 -2
  5. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/benches/core_benchmarks.rs +3 -1
  6. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-python/Cargo.toml +1 -2
  7. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-python/src/lib.rs +22 -21
  8. {polyxml-0.2.1 → polyxml-0.3.0}/pyproject.toml +1 -1
  9. {polyxml-0.2.1 → polyxml-0.3.0}/README.md +0 -0
  10. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/README.md +0 -0
  11. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/src/converters.rs +0 -0
  12. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/src/error.rs +0 -0
  13. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/src/lib.rs +0 -0
  14. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/src/parser.rs +0 -0
  15. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/src/schema.rs +0 -0
  16. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/src/serializer.rs +0 -0
  17. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/src/value.rs +0 -0
  18. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/tests/test_core.rs +0 -0
  19. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-core/tests/test_security.rs +0 -0
  20. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-python/README.md +0 -0
  21. {polyxml-0.2.1 → polyxml-0.3.0}/crates/polyxml-python/tests/test_polyxml.py +0 -0
  22. {polyxml-0.2.1 → polyxml-0.3.0}/python/polyxml/__init__.py +0 -0
  23. {polyxml-0.2.1 → polyxml-0.3.0}/python/polyxml/py.typed +0 -0
@@ -110,23 +110,20 @@ dependencies = [
110
110
 
111
111
  [[package]]
112
112
  name = "criterion"
113
- version = "0.5.1"
113
+ version = "0.7.0"
114
114
  source = "registry+https://github.com/rust-lang/crates.io-index"
115
- checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
115
+ checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928"
116
116
  dependencies = [
117
117
  "anes",
118
118
  "cast",
119
119
  "ciborium",
120
120
  "clap",
121
121
  "criterion-plot",
122
- "is-terminal",
123
122
  "itertools",
124
123
  "num-traits",
125
- "once_cell",
126
124
  "oorandom",
127
125
  "regex",
128
126
  "serde",
129
- "serde_derive",
130
127
  "serde_json",
131
128
  "tinytemplate",
132
129
  "walkdir",
@@ -134,9 +131,9 @@ dependencies = [
134
131
 
135
132
  [[package]]
136
133
  name = "criterion-plot"
137
- version = "0.5.0"
134
+ version = "0.6.0"
138
135
  source = "registry+https://github.com/rust-lang/crates.io-index"
139
- checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
136
+ checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338"
140
137
  dependencies = [
141
138
  "cast",
142
139
  "itertools",
@@ -187,12 +184,6 @@ version = "0.5.0"
187
184
  source = "registry+https://github.com/rust-lang/crates.io-index"
188
185
  checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
189
186
 
190
- [[package]]
191
- name = "hermit-abi"
192
- version = "0.5.3"
193
- source = "registry+https://github.com/rust-lang/crates.io-index"
194
- checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284"
195
-
196
187
  [[package]]
197
188
  name = "indoc"
198
189
  version = "2.0.7"
@@ -202,22 +193,11 @@ dependencies = [
202
193
  "rustversion",
203
194
  ]
204
195
 
205
- [[package]]
206
- name = "is-terminal"
207
- version = "0.4.17"
208
- source = "registry+https://github.com/rust-lang/crates.io-index"
209
- checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
210
- dependencies = [
211
- "hermit-abi",
212
- "libc",
213
- "windows-sys",
214
- ]
215
-
216
196
  [[package]]
217
197
  name = "itertools"
218
- version = "0.10.5"
198
+ version = "0.13.0"
219
199
  source = "registry+https://github.com/rust-lang/crates.io-index"
220
- checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
200
+ checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
221
201
  dependencies = [
222
202
  "either",
223
203
  ]
@@ -396,7 +376,7 @@ checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
396
376
 
397
377
  [[package]]
398
378
  name = "polyxml"
399
- version = "0.2.1"
379
+ version = "0.3.0"
400
380
  dependencies = [
401
381
  "criterion",
402
382
  "lexical-core",
@@ -409,14 +389,14 @@ dependencies = [
409
389
 
410
390
  [[package]]
411
391
  name = "polyxml-c"
412
- version = "0.2.1"
392
+ version = "0.3.0"
413
393
  dependencies = [
414
394
  "polyxml",
415
395
  ]
416
396
 
417
397
  [[package]]
418
398
  name = "polyxml-js"
419
- version = "0.2.1"
399
+ version = "0.3.0"
420
400
  dependencies = [
421
401
  "napi",
422
402
  "napi-build",
@@ -426,12 +406,11 @@ dependencies = [
426
406
 
427
407
  [[package]]
428
408
  name = "polyxml-python"
429
- version = "0.2.1"
409
+ version = "0.3.0"
430
410
  dependencies = [
431
411
  "lexical-core",
432
412
  "polyxml",
433
413
  "pyo3",
434
- "quick-xml",
435
414
  "smallvec",
436
415
  ]
437
416
 
@@ -462,9 +441,9 @@ dependencies = [
462
441
 
463
442
  [[package]]
464
443
  name = "pyo3"
465
- version = "0.22.6"
444
+ version = "0.23.5"
466
445
  source = "registry+https://github.com/rust-lang/crates.io-index"
467
- checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
446
+ checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
468
447
  dependencies = [
469
448
  "cfg-if",
470
449
  "indoc",
@@ -480,9 +459,9 @@ dependencies = [
480
459
 
481
460
  [[package]]
482
461
  name = "pyo3-build-config"
483
- version = "0.22.6"
462
+ version = "0.23.5"
484
463
  source = "registry+https://github.com/rust-lang/crates.io-index"
485
- checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
464
+ checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
486
465
  dependencies = [
487
466
  "once_cell",
488
467
  "target-lexicon",
@@ -490,9 +469,9 @@ dependencies = [
490
469
 
491
470
  [[package]]
492
471
  name = "pyo3-ffi"
493
- version = "0.22.6"
472
+ version = "0.23.5"
494
473
  source = "registry+https://github.com/rust-lang/crates.io-index"
495
- checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
474
+ checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
496
475
  dependencies = [
497
476
  "libc",
498
477
  "pyo3-build-config",
@@ -500,9 +479,9 @@ dependencies = [
500
479
 
501
480
  [[package]]
502
481
  name = "pyo3-macros"
503
- version = "0.22.6"
482
+ version = "0.23.5"
504
483
  source = "registry+https://github.com/rust-lang/crates.io-index"
505
- checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
484
+ checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
506
485
  dependencies = [
507
486
  "proc-macro2",
508
487
  "pyo3-macros-backend",
@@ -512,9 +491,9 @@ dependencies = [
512
491
 
513
492
  [[package]]
514
493
  name = "pyo3-macros-backend"
515
- version = "0.22.6"
494
+ version = "0.23.5"
516
495
  source = "registry+https://github.com/rust-lang/crates.io-index"
517
- checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
496
+ checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
518
497
  dependencies = [
519
498
  "heck",
520
499
  "proc-macro2",
@@ -525,9 +504,9 @@ dependencies = [
525
504
 
526
505
  [[package]]
527
506
  name = "quick-xml"
528
- version = "0.36.2"
507
+ version = "0.37.5"
529
508
  source = "registry+https://github.com/rust-lang/crates.io-index"
530
- checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe"
509
+ checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb"
531
510
  dependencies = [
532
511
  "memchr",
533
512
  "serde",
@@ -3,7 +3,7 @@ resolver = "2"
3
3
  members = ["crates/polyxml-core", "crates/polyxml-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.2.1"
6
+ version = "0.3.0"
7
7
  edition = "2021"
8
8
  rust-version = "1.80"
9
9
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyxml
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -11,14 +11,14 @@ keywords = ["xml", "deserializer", "serializer", "data-binding", "quick-xml"]
11
11
  categories = ["parsing", "encoding"]
12
12
 
13
13
  [dependencies]
14
- quick-xml = { version = "0.36", features = ["serialize"] }
14
+ quick-xml = { version = "0.37", features = ["serialize"] }
15
15
  lexical-core = "1.0"
16
16
  memchr = "2.8"
17
17
  thiserror = "2.0"
18
18
  smallvec = "1.16"
19
19
 
20
20
  [dev-dependencies]
21
- criterion = { version = "0.5", default-features = false, features = ["cargo_bench_support"] }
21
+ criterion = { version = "0.7", default-features = false, features = ["cargo_bench_support"] }
22
22
  pretty_assertions = "1.4"
23
23
 
24
24
  [[bench]]
@@ -1,4 +1,6 @@
1
- use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
1
+ use std::hint::black_box;
2
+
3
+ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
2
4
  use polyxml::schema::{FieldKind, FieldSchema, ModelSchema, ScalarType, ValueType};
3
5
  use polyxml::{deserialize, serialize};
4
6
  use std::sync::Arc;
@@ -14,7 +14,6 @@ crate-type = ["cdylib"]
14
14
 
15
15
  [dependencies]
16
16
  polyxml = { path = "../polyxml-core" }
17
- pyo3 = { version = "0.22", features = ["abi3-py312", "extension-module"] }
18
- quick-xml = { version = "0.36" }
17
+ pyo3 = { version = "0.23", features = ["abi3-py312", "extension-module"] }
19
18
  lexical-core = "1.0"
20
19
  smallvec = "1.16"
@@ -4,6 +4,7 @@
4
4
 
5
5
  use pyo3::prelude::*;
6
6
  use pyo3::types::{PyBytes, PyDict, PyList, PyString, PyTuple, PyType};
7
+ use pyo3::IntoPyObjectExt;
7
8
  use std::collections::HashMap;
8
9
  use std::sync::{Arc, RwLock};
9
10
 
@@ -69,7 +70,7 @@ fn unwrap_optional_type<'py>(type_obj: &Bound<'py, PyAny>) -> Bound<'py, PyAny>
69
70
 
70
71
  fn is_enum_class<'py>(py: Python<'py>, cls: &Bound<'py, PyAny>) -> bool {
71
72
  if let Ok(py_type) = cls.downcast::<PyType>() {
72
- if let Ok(enum_module) = py.import_bound("enum") {
73
+ if let Ok(enum_module) = py.import("enum") {
73
74
  if let Ok(enum_cls) = enum_module.getattr("Enum") {
74
75
  if let Ok(py_enum) = enum_cls.downcast::<PyType>() {
75
76
  return py_type.is_subclass(py_enum).unwrap_or(false);
@@ -160,7 +161,7 @@ fn extract_schema_from_class<'py>(
160
161
  let mut cached_fields = Vec::new();
161
162
 
162
163
  let type_hints: Option<Bound<'py, PyDict>> = py
163
- .import_bound("typing")
164
+ .import("typing")
164
165
  .ok()
165
166
  .and_then(|m| m.getattr("get_type_hints").ok())
166
167
  .and_then(|f| f.call1((cls,)).ok())
@@ -170,7 +171,7 @@ fn extract_schema_from_class<'py>(
170
171
  let model_fields: Bound<'py, PyDict> = cls.getattr("model_fields")?.downcast_into()?;
171
172
  for (name_obj, field_obj) in model_fields.iter() {
172
173
  let py_name: String = name_obj.extract()?;
173
- let py_string = PyString::new_bound(py, &py_name).unbind();
174
+ let py_string = PyString::new(py, &py_name).unbind();
174
175
  let mut xml_name = py_name.clone();
175
176
  let mut kind = FieldKind::Element;
176
177
 
@@ -223,7 +224,7 @@ fn extract_schema_from_class<'py>(
223
224
  let fields: Bound<'py, PyDict> = cls.getattr("__dataclass_fields__")?.downcast_into()?;
224
225
  for (name_obj, field_obj) in fields.iter() {
225
226
  let py_name: String = name_obj.extract()?;
226
- let py_string = PyString::new_bound(py, &py_name).unbind();
227
+ let py_string = PyString::new(py, &py_name).unbind();
227
228
  let mut xml_name = py_name.clone();
228
229
  let mut kind = FieldKind::Element;
229
230
 
@@ -333,7 +334,7 @@ fn convert_scalar_to_py<'py>(
333
334
  ) -> PyResult<PyObject> {
334
335
  match val {
335
336
  PolyValue::Null => Ok(py.None()),
336
- PolyValue::Bool(b) => Ok(b.to_object(py)),
337
+ PolyValue::Bool(b) => b.into_py_any(py),
337
338
  PolyValue::Int(i) => {
338
339
  if let Some(target_type) = py_type_opt {
339
340
  if is_enum_class(py, target_type) {
@@ -342,9 +343,9 @@ fn convert_scalar_to_py<'py>(
342
343
  }
343
344
  }
344
345
  }
345
- Ok(i.to_object(py))
346
+ i.into_py_any(py)
346
347
  }
347
- PolyValue::Float(f) => Ok(f.to_object(py)),
348
+ PolyValue::Float(f) => f.into_py_any(py),
348
349
  PolyValue::String(s) => {
349
350
  if let Some(target_type) = py_type_opt {
350
351
  if is_enum_class(py, target_type) {
@@ -368,7 +369,7 @@ fn convert_scalar_to_py<'py>(
368
369
 
369
370
  match type_name.as_str() {
370
371
  "Decimal" => {
371
- let decimal_cls = py.import_bound("decimal")?.getattr("Decimal")?;
372
+ let decimal_cls = py.import("decimal")?.getattr("Decimal")?;
372
373
  let dec = decimal_cls.call1((s.as_str(),))?;
373
374
  return Ok(dec.unbind());
374
375
  }
@@ -376,7 +377,7 @@ fn convert_scalar_to_py<'py>(
376
377
  if let Ok(val) = target_type.call_method1("from_string", (s.as_str(),)) {
377
378
  return Ok(val.unbind());
378
379
  }
379
- if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
380
+ if let Ok(datatype_mod) = py.import("pyxsdata.models.datatype") {
380
381
  if let Ok(cls) = datatype_mod.getattr(type_name.as_str()) {
381
382
  if let Ok(val) = cls.call_method1("from_string", (s.as_str(),)) {
382
383
  return Ok(val.unbind());
@@ -392,7 +393,7 @@ fn convert_scalar_to_py<'py>(
392
393
  "XmlTime" => "time",
393
394
  _ => "",
394
395
  };
395
- if let Ok(datetime_mod) = py.import_bound("datetime") {
396
+ if let Ok(datetime_mod) = py.import("datetime") {
396
397
  if let Ok(cls) = datetime_mod.getattr(mod_name) {
397
398
  if let Ok(val) = cls.call_method1("fromisoformat", (s.as_str(),)) {
398
399
  return Ok(val.unbind());
@@ -404,7 +405,7 @@ fn convert_scalar_to_py<'py>(
404
405
  if let Ok(val) = target_type.call1((s.as_str(),)) {
405
406
  return Ok(val.unbind());
406
407
  }
407
- if let Ok(datatype_mod) = py.import_bound("pyxsdata.models.datatype") {
408
+ if let Ok(datatype_mod) = py.import("pyxsdata.models.datatype") {
408
409
  if let Ok(cls) = datatype_mod.getattr("XmlDuration") {
409
410
  if let Ok(val) = cls.call1((s.as_str(),)) {
410
411
  return Ok(val.unbind());
@@ -415,7 +416,7 @@ fn convert_scalar_to_py<'py>(
415
416
  _ => {}
416
417
  }
417
418
  }
418
- Ok(PyString::new_bound(py, s).into_any().unbind())
419
+ Ok(PyString::new(py, s).into_any().unbind())
419
420
  }
420
421
  _ => Ok(py.None()),
421
422
  }
@@ -430,7 +431,7 @@ fn poly_value_to_py<'py>(
430
431
  ) -> PyResult<PyObject> {
431
432
  match val {
432
433
  PolyValue::Null => Ok(py.None()),
433
- PolyValue::Bool(b) => Ok(b.to_object(py)),
434
+ PolyValue::Bool(b) => b.into_py_any(py),
434
435
  PolyValue::Int(_) | PolyValue::Float(_) | PolyValue::String(_) => {
435
436
  let st = match val_type {
436
437
  ValueType::Scalar(ref s) => s,
@@ -456,10 +457,10 @@ fn poly_value_to_py<'py>(
456
457
  poly_value_to_py(py, item, inner_type, inner_cls.as_ref(), field_meta)?;
457
458
  py_items.push(py_item);
458
459
  }
459
- let py_list = PyList::new_bound(py, &py_items);
460
+ let py_list = PyList::new(py, &py_items)?;
460
461
  Ok(py_list.into_any().unbind())
461
462
  } else {
462
- let py_list = PyList::empty_bound(py);
463
+ let py_list = PyList::empty(py);
463
464
  Ok(py_list.into_any().unbind())
464
465
  }
465
466
  }
@@ -508,7 +509,7 @@ fn poly_value_to_py<'py>(
508
509
  }
509
510
  }
510
511
  if all_found {
511
- let tuple = pyo3::types::PyTuple::new_bound(py, &args_vec);
512
+ let tuple = pyo3::types::PyTuple::new(py, &args_vec)?;
512
513
  if let Ok(instance) = target_cls.call1(tuple) {
513
514
  return Ok(instance.unbind());
514
515
  }
@@ -517,7 +518,7 @@ fn poly_value_to_py<'py>(
517
518
  }
518
519
 
519
520
  // Method 2: Keyword arguments with init=False post-init support
520
- let kwargs = PyDict::new_bound(py);
521
+ let kwargs = PyDict::new(py);
521
522
  let mut post_init_fields: Vec<(Py<PyString>, PyObject)> = Vec::new();
522
523
 
523
524
  for (i, field) in schema.fields.iter().enumerate() {
@@ -546,7 +547,7 @@ fn poly_value_to_py<'py>(
546
547
  kwargs.set_item(&field.name, py_val)?;
547
548
  } else {
548
549
  post_init_fields
549
- .push((PyString::new_bound(py, &field.name).unbind(), py_val));
550
+ .push((PyString::new(py, &field.name).unbind(), py_val));
550
551
  }
551
552
  }
552
553
  }
@@ -556,7 +557,7 @@ fn poly_value_to_py<'py>(
556
557
  }
557
558
  return Ok(instance.unbind());
558
559
  }
559
- let dict = PyDict::new_bound(py);
560
+ let dict = PyDict::new(py);
560
561
  for (k, v) in map {
561
562
  let py_v =
562
563
  poly_value_to_py(py, v, &ValueType::Scalar(ScalarType::Any), None, None)?;
@@ -565,7 +566,7 @@ fn poly_value_to_py<'py>(
565
566
  let instance = target_cls.call((), Some(&dict))?;
566
567
  Ok(instance.unbind())
567
568
  } else {
568
- let dict = PyDict::new_bound(py);
569
+ let dict = PyDict::new(py);
569
570
  for (k, v) in map {
570
571
  let py_v =
571
572
  poly_value_to_py(py, v, &ValueType::Scalar(ScalarType::Any), None, None)?;
@@ -763,7 +764,7 @@ fn serialize<'py>(
763
764
  let bytes = polyxml::serialize(root_name, &poly_val, &meta.schema, indent)
764
765
  .map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))?;
765
766
 
766
- Ok(PyBytes::new_bound(py, &bytes))
767
+ Ok(PyBytes::new(py, &bytes))
767
768
  }
768
769
 
769
770
  #[pyfunction]
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "polyxml"
7
- version = "0.2.1"
7
+ version = "0.3.0"
8
8
  description = "High-performance, polyglot XML data-binding engine built in Rust"
9
9
  authors = [
10
10
  { name = "Bailey Nguyen", email = "bailey.tan.nguyen@gmail.com" }
File without changes
File without changes