File: test_nested_benchmark.py

package info (click to toggle)
pydantic-core 2.41.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 3,836 kB
  • sloc: python: 35,821; javascript: 211; makefile: 128
file content (23 lines) | stat: -rw-r--r-- 653 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Benchmarks for nested / recursive schemas using definitions.
"""

from typing import Callable

from pydantic_core import SchemaValidator

from .nested_schema import inlined_schema, input_data_valid, schema_using_defs


def test_nested_schema_using_defs(benchmark: Callable[..., None]) -> None:
    v = SchemaValidator(schema_using_defs())
    data = input_data_valid()
    v.validate_python(data)
    benchmark(v.validate_python, data)


def test_nested_schema_inlined(benchmark: Callable[..., None]) -> None:
    v = SchemaValidator(inlined_schema())
    data = input_data_valid()
    v.validate_python(data)
    benchmark(v.validate_python, data)