Skip to content

Commit d7cdc85

Browse files
authored
bump pyo3 to 0.26, jiter to 0.11 (#1785)
1 parent cbe2dd2 commit d7cdc85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+339
-345
lines changed

Cargo.lock

Lines changed: 14 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ rust-version = "1.75"
2727
[dependencies]
2828
# TODO it would be very nice to remove the "py-clone" feature as it can panic,
2929
# but needs a bit of work to make sure it's not used in the codebase
30-
pyo3 = { version = "0.25", features = ["generate-import-lib", "num-bigint", "py-clone"] }
30+
pyo3 = { version = "0.26", features = ["generate-import-lib", "num-bigint", "py-clone"] }
3131
regex = "1.11.1"
3232
strum = { version = "0.27", features = ["derive"] }
3333
strum_macros = "0.27"
@@ -44,17 +44,13 @@ base64 = "0.22.1"
4444
num-bigint = "0.4.6"
4545
num-traits = "0.2.19"
4646
uuid = "1.17.0"
47-
jiter = { version = "0.10.0", features = ["python"] }
47+
jiter = { version = "0.11.0", features = ["python"] }
4848
hex = "0.4.3"
4949

5050
[lib]
5151
name = "_pydantic_core"
5252
crate-type = ["cdylib", "rlib"]
5353

54-
[features]
55-
# must be enabled when building with `cargo build`, maturin enables this automatically
56-
extension-module = ["pyo3/extension-module"]
57-
5854
[profile.release]
5955
lto = "fat"
6056
codegen-units = 1
@@ -72,12 +68,12 @@ debug = true
7268
strip = false
7369

7470
[dev-dependencies]
75-
pyo3 = { version = "0.25", features = ["auto-initialize"] }
71+
pyo3 = { version = "0.26", features = ["auto-initialize"] }
7672

7773
[build-dependencies]
7874
version_check = "0.9.5"
7975
# used where logic has to be version/distribution specific, e.g. pypy
80-
pyo3-build-config = { version = "0.25" }
76+
pyo3-build-config = { version = "0.26" }
8177

8278
[lints.clippy]
8379
dbg_macro = "warn"

benches/main.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn json<'a>(py: Python<'a>, code: &'a str) -> Bound<'a, PyAny> {
2929

3030
#[bench]
3131
fn ints_json(bench: &mut Bencher) {
32-
Python::with_gil(|py| {
32+
Python::attach(|py| {
3333
let validator = build_schema_validator(py, c"{'type': 'int'}");
3434

3535
let result = validator
@@ -50,7 +50,7 @@ fn ints_json(bench: &mut Bencher) {
5050

5151
#[bench]
5252
fn ints_python(bench: &mut Bencher) {
53-
Python::with_gil(|py| {
53+
Python::attach(|py| {
5454
let validator = build_schema_validator(py, c"{'type': 'int'}");
5555

5656
let Ok(input) = 123_i64.into_pyobject(py);
@@ -73,7 +73,7 @@ fn ints_python(bench: &mut Bencher) {
7373

7474
#[bench]
7575
fn list_int_json(bench: &mut Bencher) {
76-
Python::with_gil(|py| {
76+
Python::attach(|py| {
7777
let validator = build_schema_validator(py, c"{'type': 'list', 'items_schema': {'type': 'int'}}");
7878
let code = format!(
7979
"[{}]",
@@ -104,7 +104,7 @@ fn list_int_input(py: Python<'_>) -> (SchemaValidator, PyObject) {
104104

105105
#[bench]
106106
fn list_int_python(bench: &mut Bencher) {
107-
Python::with_gil(|py| {
107+
Python::attach(|py| {
108108
let (validator, input) = list_int_input(py);
109109
let input = black_box(input.bind(py));
110110
bench.iter(|| {
@@ -118,7 +118,7 @@ fn list_int_python(bench: &mut Bencher) {
118118

119119
#[bench]
120120
fn list_int_python_isinstance(bench: &mut Bencher) {
121-
Python::with_gil(|py| {
121+
Python::attach(|py| {
122122
let (validator, input) = list_int_input(py);
123123
let input = black_box(input.bind(py));
124124
let v = validator
@@ -137,7 +137,7 @@ fn list_int_python_isinstance(bench: &mut Bencher) {
137137

138138
#[bench]
139139
fn list_error_json(bench: &mut Bencher) {
140-
Python::with_gil(|py| {
140+
Python::attach(|py| {
141141
let validator = build_schema_validator(py, c"{'type': 'list', 'items_schema': {'type': 'int'}}");
142142
let code = format!(
143143
"[{}]",
@@ -195,7 +195,7 @@ fn list_error_python_input(py: Python<'_>) -> (SchemaValidator, PyObject) {
195195

196196
#[bench]
197197
fn list_error_python(bench: &mut Bencher) {
198-
Python::with_gil(|py| {
198+
Python::attach(|py| {
199199
let (validator, input) = list_error_python_input(py);
200200

201201
let input = black_box(input.bind(py));
@@ -212,7 +212,7 @@ fn list_error_python(bench: &mut Bencher) {
212212

213213
#[bench]
214214
fn list_error_python_isinstance(bench: &mut Bencher) {
215-
Python::with_gil(|py| {
215+
Python::attach(|py| {
216216
let (validator, input) = list_error_python_input(py);
217217
let input = black_box(input.bind(py));
218218
let r = validator
@@ -232,7 +232,7 @@ fn list_error_python_isinstance(bench: &mut Bencher) {
232232

233233
#[bench]
234234
fn list_any_json(bench: &mut Bencher) {
235-
Python::with_gil(|py| {
235+
Python::attach(|py| {
236236
let validator = build_schema_validator(py, c"{'type': 'list'}");
237237
let code = format!(
238238
"[{}]",
@@ -251,7 +251,7 @@ fn list_any_json(bench: &mut Bencher) {
251251

252252
#[bench]
253253
fn list_any_python(bench: &mut Bencher) {
254-
Python::with_gil(|py| {
254+
Python::attach(|py| {
255255
let validator = build_schema_validator(py, c"{'type': 'list'}");
256256
let code = CString::new(format!(
257257
"[{}]",
@@ -279,7 +279,7 @@ fn as_str(i: u8) -> String {
279279

280280
#[bench]
281281
fn dict_json(bench: &mut Bencher) {
282-
Python::with_gil(|py| {
282+
Python::attach(|py| {
283283
let validator = build_schema_validator(
284284
py,
285285
c"{'type': 'dict', 'keys_schema': {'type': 'str'}, 'values_schema': {'type': 'int'}}",
@@ -305,7 +305,7 @@ fn dict_json(bench: &mut Bencher) {
305305

306306
#[bench]
307307
fn dict_python(bench: &mut Bencher) {
308-
Python::with_gil(|py| {
308+
Python::attach(|py| {
309309
let validator = build_schema_validator(
310310
py,
311311
c"{'type': 'dict', 'keys_schema': {'type': 'str'}, 'values_schema': {'type': 'int'}}",
@@ -332,7 +332,7 @@ fn dict_python(bench: &mut Bencher) {
332332

333333
#[bench]
334334
fn dict_value_error(bench: &mut Bencher) {
335-
Python::with_gil(|py| {
335+
Python::attach(|py| {
336336
let validator = build_schema_validator(
337337
py,
338338
cr"{
@@ -378,7 +378,7 @@ fn dict_value_error(bench: &mut Bencher) {
378378

379379
#[bench]
380380
fn typed_dict_json(bench: &mut Bencher) {
381-
Python::with_gil(|py| {
381+
Python::attach(|py| {
382382
let validator = build_schema_validator(
383383
py,
384384
cr"{
@@ -413,7 +413,7 @@ fn typed_dict_json(bench: &mut Bencher) {
413413

414414
#[bench]
415415
fn typed_dict_python(bench: &mut Bencher) {
416-
Python::with_gil(|py| {
416+
Python::attach(|py| {
417417
let validator = build_schema_validator(
418418
py,
419419
cr"{
@@ -448,7 +448,7 @@ fn typed_dict_python(bench: &mut Bencher) {
448448

449449
#[bench]
450450
fn typed_dict_deep_error(bench: &mut Bencher) {
451-
Python::with_gil(|py| {
451+
Python::attach(|py| {
452452
let validator = build_schema_validator(
453453
py,
454454
cr"{
@@ -504,7 +504,7 @@ fn typed_dict_deep_error(bench: &mut Bencher) {
504504

505505
#[bench]
506506
fn complete_model(bench: &mut Bencher) {
507-
Python::with_gil(|py| {
507+
Python::attach(|py| {
508508
let sys_path = py.import("sys").unwrap().getattr("path").unwrap();
509509
sys_path.call_method1("append", ("./tests/benchmarks/",)).unwrap();
510510

@@ -527,7 +527,7 @@ fn complete_model(bench: &mut Bencher) {
527527

528528
#[bench]
529529
fn nested_model_using_definitions(bench: &mut Bencher) {
530-
Python::with_gil(|py| {
530+
Python::attach(|py| {
531531
let sys_path = py.import("sys").unwrap().getattr("path").unwrap();
532532
sys_path.call_method1("append", ("./tests/benchmarks/",)).unwrap();
533533

@@ -554,7 +554,7 @@ fn nested_model_using_definitions(bench: &mut Bencher) {
554554

555555
#[bench]
556556
fn nested_model_inlined(bench: &mut Bencher) {
557-
Python::with_gil(|py| {
557+
Python::attach(|py| {
558558
let sys_path = py.import("sys").unwrap().getattr("path").unwrap();
559559
sys_path.call_method1("append", ("./tests/benchmarks/",)).unwrap();
560560

@@ -581,7 +581,7 @@ fn nested_model_inlined(bench: &mut Bencher) {
581581

582582
#[bench]
583583
fn literal_ints_few_python(bench: &mut Bencher) {
584-
Python::with_gil(|py| {
584+
Python::attach(|py| {
585585
let validator = build_schema_validator(py, c"{'type': 'literal', 'expected': list(range(5))}");
586586

587587
let Ok(input) = 4_i64.into_pyobject(py);
@@ -604,7 +604,7 @@ fn literal_ints_few_python(bench: &mut Bencher) {
604604

605605
#[bench]
606606
fn literal_strings_few_small_python(bench: &mut Bencher) {
607-
Python::with_gil(|py| {
607+
Python::attach(|py| {
608608
let validator = build_schema_validator(py, c"{'type': 'literal', 'expected': [f'{idx}' for idx in range(5)]}");
609609

610610
let input = py.eval(c"'4'", None, None).unwrap();
@@ -628,7 +628,7 @@ fn literal_strings_few_small_python(bench: &mut Bencher) {
628628

629629
#[bench]
630630
fn literal_strings_few_large_python(bench: &mut Bencher) {
631-
Python::with_gil(|py| {
631+
Python::attach(|py| {
632632
let validator = build_schema_validator(
633633
py,
634634
c"{'type': 'literal', 'expected': ['a' * 25 + f'{idx}' for idx in range(5)]}",
@@ -655,7 +655,7 @@ fn literal_strings_few_large_python(bench: &mut Bencher) {
655655

656656
#[bench]
657657
fn literal_enums_few_python(bench: &mut Bencher) {
658-
Python::with_gil(|py| {
658+
Python::attach(|py| {
659659
let globals = PyDict::new(py);
660660
py.run(
661661
cr"
@@ -697,7 +697,7 @@ class Foo(Enum):
697697

698698
#[bench]
699699
fn literal_ints_many_python(bench: &mut Bencher) {
700-
Python::with_gil(|py| {
700+
Python::attach(|py| {
701701
let validator = build_schema_validator(py, c"{'type': 'literal', 'expected': list(range(100))}");
702702

703703
let Ok(input) = 99_i64.into_pyobject(py);
@@ -720,7 +720,7 @@ fn literal_ints_many_python(bench: &mut Bencher) {
720720

721721
#[bench]
722722
fn literal_strings_many_small_python(bench: &mut Bencher) {
723-
Python::with_gil(|py| {
723+
Python::attach(|py| {
724724
let validator =
725725
build_schema_validator(py, c"{'type': 'literal', 'expected': [f'{idx}' for idx in range(100)]}");
726726

@@ -745,7 +745,7 @@ fn literal_strings_many_small_python(bench: &mut Bencher) {
745745

746746
#[bench]
747747
fn literal_strings_many_large_python(bench: &mut Bencher) {
748-
Python::with_gil(|py| {
748+
Python::attach(|py| {
749749
let validator = build_schema_validator(
750750
py,
751751
c"{'type': 'literal', 'expected': ['a' * 25 + f'{idx}' for idx in range(100)]}",
@@ -772,7 +772,7 @@ fn literal_strings_many_large_python(bench: &mut Bencher) {
772772

773773
#[bench]
774774
fn literal_ints_many_json(bench: &mut Bencher) {
775-
Python::with_gil(|py| {
775+
Python::attach(|py| {
776776
let validator = build_schema_validator(py, c"{'type': 'literal', 'expected': list(range(100))}");
777777

778778
let input_json = py.eval(c"'99'", None, None).unwrap();
@@ -795,7 +795,7 @@ fn literal_ints_many_json(bench: &mut Bencher) {
795795

796796
#[bench]
797797
fn literal_strings_many_large_json(bench: &mut Bencher) {
798-
Python::with_gil(|py| {
798+
Python::attach(|py| {
799799
let validator = build_schema_validator(
800800
py,
801801
c"{'type': 'literal', 'expected': ['a' * 25 + f'{idx}' for idx in range(100)]}",
@@ -823,7 +823,7 @@ fn literal_strings_many_large_json(bench: &mut Bencher) {
823823

824824
#[bench]
825825
fn literal_mixed_few_python(bench: &mut Bencher) {
826-
Python::with_gil(|py| {
826+
Python::attach(|py| {
827827
let globals = PyDict::new(py);
828828
py.run(
829829
cr"

0 commit comments

Comments
 (0)