Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ Speed up function apply_each_item_validators by 100% in pydantic/_internal/_generate_schema.py #26

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Commits on Jul 18, 2024

  1. ⚡️ Speed up function apply_each_item_validators by 100%

    Below is an optimized version of the same Python program. The changes aim to improve execution speed by reducing redundant operations and simplifying some parts of the code.
    
    
    
    ### Changes Made.
    1. **Use of `slots` in `dataclass`**: Added `slots=True` to the `ValidatorDecoratorInfo` and `Decorator` classes to reduce memory usage.
    2. **Streamlined `build` method**: Consolidated the logic within the `build` method to streamline function unwrapping and avoid repeated code.
    3. **Avoid Redundant Type Checking**: In `apply_each_item_validators`, added a quick return if `each_item_validators` is empty.
    4. **Simplified Schema Handling**: Minimized redundant dictionary key accesses and introduced the use of `get` with default values.
    
    These optimizations should enhance the performance and maintainability of the code without changing its external behavior.
    codeflash-ai[bot] authored Jul 18, 2024
    Configuration menu
    Copy the full SHA
    cf598e6 View commit details
    Browse the repository at this point in the history

Commits on Jul 23, 2024

  1. Fix formatting

    misrasaurabh1 committed Jul 23, 2024
    Configuration menu
    Copy the full SHA
    a70190e View commit details
    Browse the repository at this point in the history
  2. Fix formatting

    misrasaurabh1 committed Jul 23, 2024
    Configuration menu
    Copy the full SHA
    6726b0c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7501750 View commit details
    Browse the repository at this point in the history

Commits on Jul 29, 2024

  1. Update pydantic/_internal/_generate_schema.py

    Co-authored-by: Sydney Runkle <[email protected]>
    misrasaurabh1 and sydney-runkle authored Jul 29, 2024
    Configuration menu
    Copy the full SHA
    9aaa3cf View commit details
    Browse the repository at this point in the history