Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ serde = "1.0.137"
indexmap = "1.8.1"
mimalloc = { version = "0.1.29", default-features = false, optional = true }
speedate = "0.4.1"
ahash = "0.7.6"

[lib]
name = "_pydantic_core"
Expand Down
20 changes: 10 additions & 10 deletions src/validators/literal.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashSet;

use pyo3::prelude::*;
use pyo3::types::{PyDict, PyList};

use ahash::AHashSet;

use crate::build_tools::{py_error, SchemaDict};
use crate::errors::{as_internal, context, err_val_error, ErrorKind, ValResult};
use crate::input::Input;
Expand Down Expand Up @@ -119,13 +119,13 @@ impl Validator for LiteralSingleIntValidator {

#[derive(Debug, Clone)]
pub struct LiteralMultipleStringsValidator {
expected: HashSet<String>,
expected: AHashSet<String>,
repr: String,
}

impl LiteralMultipleStringsValidator {
fn new(expected_list: &PyList) -> Option<Self> {
let mut expected: HashSet<String> = HashSet::new();
let mut expected: AHashSet<String> = AHashSet::new();
let mut repr_args = Vec::new();
for item in expected_list.iter() {
if let Ok(str) = item.extract() {
Expand Down Expand Up @@ -170,13 +170,13 @@ impl Validator for LiteralMultipleStringsValidator {

#[derive(Debug, Clone)]
pub struct LiteralMultipleIntsValidator {
expected: HashSet<i64>,
expected: AHashSet<i64>,
repr: String,
}

impl LiteralMultipleIntsValidator {
fn new(expected_list: &PyList) -> Option<Self> {
let mut expected: HashSet<i64> = HashSet::new();
let mut expected: AHashSet<i64> = AHashSet::new();
let mut repr_args = Vec::new();
for item in expected_list.iter() {
if let Ok(str) = item.extract() {
Expand Down Expand Up @@ -221,16 +221,16 @@ impl Validator for LiteralMultipleIntsValidator {

#[derive(Debug, Clone)]
pub struct LiteralGeneralValidator {
expected_int: HashSet<i64>,
expected_str: HashSet<String>,
expected_int: AHashSet<i64>,
expected_str: AHashSet<String>,
expected_py: Py<PyList>,
repr: String,
}

impl LiteralGeneralValidator {
fn new(expected: &PyList) -> PyResult<Self> {
let mut expected_int = HashSet::new();
let mut expected_str = HashSet::new();
let mut expected_int = AHashSet::new();
let mut expected_str = AHashSet::new();
let py = expected.py();
let expected_py = PyList::empty(py);
let mut repr_args: Vec<String> = Vec::new();
Expand Down
7 changes: 4 additions & 3 deletions src/validators/typed_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use pyo3::exceptions::{PyAttributeError, PyTypeError};
use pyo3::intern;
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyFunction, PyList, PySet, PyString};
use std::collections::HashSet;

use ahash::AHashSet;

use crate::build_tools::{py_error, SchemaDict};
use crate::errors::{
Expand Down Expand Up @@ -143,8 +144,8 @@ impl Validator for TypedDictValidator {

// we only care about which keys have been used if we're iterating over the object for extra after
// the first pass
let mut used_keys: Option<HashSet<&str>> = match self.check_extra {
true => Some(HashSet::with_capacity(self.fields.len())),
let mut used_keys: Option<AHashSet<&str>> = match self.check_extra {
true => Some(AHashSet::with_capacity(self.fields.len())),
false => None,
};

Expand Down