Skip to content

Nested Pydantic schema causes slow performance #2026

@zsol

Description

@zsol

Summary

For example checking the following takes 11s, but the real world example this is taken from takes many minutes (and is a bit more nested):

from pydantic_core import core_schema

core_schema.union_schema(
    [
        core_schema.is_instance_schema(...),
        core_schema.chain_schema(
            [
                core_schema.no_info_after_validator_function(
                    function=lambda data: data,
                    schema=core_schema.list_schema(
                        core_schema.list_schema(
                            core_schema.list_schema(),
                        )
                    ),
                ),
            ]
        ),
    ],
)

Version

0.0.2 with #22030 applied

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePotential performance improvement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions