Skip to content

Commit 9bc02dd

Browse files
⚡️ Speed up function check_validator_fields_against_field_name by 18%
Here's the rewritten version of the `check_validator_fields_against_field_name` function, optimized for faster execution.
1 parent 9bcb120 commit 9bc02dd

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

pydantic/_internal/_generate_schema.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,7 @@ def check_validator_fields_against_field_name(
124124
Returns:
125125
`True` if field name is in validator fields, `False` otherwise.
126126
"""
127-
if '*' in info.fields:
128-
return True
129-
for v_field_name in info.fields:
130-
if v_field_name == field:
131-
return True
132-
return False
127+
return '*' in info.fields or field in info.fields
133128

134129

135130
def check_decorator_fields_exist(decorators: Iterable[AnyFieldDecorator], fields: Iterable[str]) -> None:

0 commit comments

Comments
 (0)