## Change Summary

This means `pydantic/__init__.py` is now lazy about all imports using `__getattr__`.

Import performance changes:
### Before

```
code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "import pydantic"
1 loop, best of 1: 29.7 msec per loop
```

```
code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "from pydantic import BaseModel"
1 loop, best of 1: 30.4 msec per loop
```

### After

```
code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "import pydantic"
1 loop, best of 1: 4.8 msec per loop
```

```
(env3112) code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "from pydantic import BaseModel"           
1 loop, best of 1: 18.7 msec per loop
```

Tuna output:

<img width="1421" alt="image" src="https://github.com/pydantic/pydantic/assets/4039449/0a57434e-fdda-4709-8793-d96c0a0ee762">

## Related issue number

As promised in https://github.com/pydantic/pydantic/pull/7423#issuecomment-1733361629.

## Checklist

* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [ ] Unit tests for the changes exist
* [x] Tests pass on CI
* [ ] Documentation reflects the changes where applicable
* [x] My PR is ready to review, **please add a comment including the phrase "please review" to assign reviewers**


Selected Reviewer: @sydney-runkle
Use `__getattr__` for all package imports, improve import time. ## Change Summary

This means `pydantic/__init__.py` is now lazy about all imports using `__getattr__`.

Import performance changes:
### Before

```
code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "import pydantic"
1 loop, best of 1: 29.7 msec per loop
```

```
code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "from pydantic import BaseModel"
1 loop, best of 1: 30.4 msec per loop
```

### After

```
code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "import pydantic"
1 loop, best of 1: 4.8 msec per loop
```

```
(env3112) code/pydantic 0 ➤ pdm run python -m timeit -n 1 -r 1 "from pydantic import BaseModel"           
1 loop, best of 1: 18.7 msec per loop
```

Tuna output:

<img width="1421" alt="image" src="https://github.com/pydantic/pydantic/assets/4039449/0a57434e-fdda-4709-8793-d96c0a0ee762">

## Related issue number

As promised in https://github.com/pydantic/pydantic/pull/7423#issuecomment-1733361629.

## Checklist

* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [ ] Unit tests for the changes exist
* [x] Tests pass on CI
* [ ] Documentation reflects the changes where applicable
* [x] My PR is ready to review, **please add a comment including the phrase "please review" to assign reviewers**


Selected Reviewer: @sydney-runkle
name: Dependencies Check

on:
  schedule:
  - cron: '43 3 * * 6,3'
  workflow_dispatch: {}

jobs:
  find_dependency_cases:
    runs-on: ubuntu-latest

    outputs:
      PYTHON_DEPENDENCY_CASES: ${{ steps.list-python-dependencies.outputs.PYTHON_DEPENDENCY_CASES }}

    steps:
    - uses: actions/checkout@v4
    - uses: samuelcolvin/list-python-dependencies@main
      id: list-python-dependencies
      with:
        mode: first-last

  test:
    name: test py${{ matrix.python-version }} on ${{ matrix.PYTHON_DEPENDENCY_CASE }}

    needs:
    - find_dependency_cases

    strategy:
      fail-fast: true
      matrix:
        python-version: ['3.7', '3.11']
        PYTHON_DEPENDENCY_CASE: ${{ fromJSON(needs.find_dependency_cases.outputs.PYTHON_DEPENDENCY_CASES) }}

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - name: set up python
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - run: pip install pdm && pdm install --no-isolation

    - run: pdm run pip install ${{ matrix.PYTHON_DEPENDENCY_CASE }}

    - run: pdm run pip freeze

    - run: make test

name: Dependencies Check

on:
  schedule:
  - cron: '43 3 * * 6,3'
  workflow_dispatch: {}

jobs:
  find_dependency_cases:
    runs-on: ubuntu-latest

    outputs:
      PYTHON_DEPENDENCY_CASES: ${{ steps.list-python-dependencies.outputs.PYTHON_DEPENDENCY_CASES }}

    steps:
    - uses: actions/checkout@v4
    - uses: samuelcolvin/list-python-dependencies@main
      id: list-python-dependencies
      with:
        mode: first-last

  test:
    name: test py${{ matrix.python-version }} on ${{ matrix.PYTHON_DEPENDENCY_CASE }}

    needs:
    - find_dependency_cases

    strategy:
      fail-fast: true
      matrix:
        python-version: ['3.7', '3.11']
        PYTHON_DEPENDENCY_CASE: ${{ fromJSON(needs.find_dependency_cases.outputs.PYTHON_DEPENDENCY_CASES) }}

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - name: set up python
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - run: pip install pdm && pdm install --no-isolation

    - run: pdm run pip install ${{ matrix.PYTHON_DEPENDENCY_CASE }}

    - run: pdm run pip freeze

    - run: make test
