Skip to content

Commit

Permalink
fix rust benches
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Sep 21, 2023
1 parent 9b79b0c commit d235d90
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ use test::{black_box, Bencher};
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyString};

use _pydantic_core::SchemaValidator;
use _pydantic_core::{validate_core_schema, SchemaValidator};

fn build_schema_validator_with_globals(py: Python, code: &str, globals: Option<&PyDict>) -> SchemaValidator {
let schema: &PyDict = py.eval(code, globals, None).unwrap().extract().unwrap();
let mut schema: &PyDict = py.eval(code, globals, None).unwrap().extract().unwrap();
schema = validate_core_schema(py, schema).unwrap().extract().unwrap();
SchemaValidator::py_new(py, schema, None).unwrap()
}

Expand Down Expand Up @@ -444,7 +445,8 @@ fn complete_model(bench: &mut Bencher) {
sys_path.call_method1("append", ("./tests/benchmarks/",)).unwrap();

let complete_schema = py.import("complete_schema").unwrap();
let schema = complete_schema.call_method0("schema").unwrap();
let mut schema = complete_schema.call_method0("schema").unwrap();
schema = validate_core_schema(py, schema).unwrap().extract().unwrap();
let validator = SchemaValidator::py_new(py, schema, None).unwrap();

let input = complete_schema.call_method0("input_data_lax").unwrap();
Expand Down

0 comments on commit d235d90

Please sign in to comment.