Open adriamontoto opened 2 months ago
Yeah we could probably handle this case better, bc a range is a valid sequence, and there's probably a clever way to validate the contents of the range without iterating through each item.
I think really this is more a task of "support efficient validation of ranges as sequences"
@sydney-runkle Do you want me to change the issue title?
Initial Checks
Description
When a large range is passed to a function with a Sequence annotation using the validate_call decorator from Pydantic, the system encounters issues due to the validation process. Despite ranges being lazy sequences that do not require memory allocation for all elements, the validation process seems to handle it inefficiently, leading to crashes with extremely large ranges.
It happens with
from collections.abc import Sequence
andfrom typing import Sequence
.Example Code
Python, Pydantic & OS Version
Windows Machine
Linux Machine