gabrieldemarmiesse / python-on-whales

An awesome Python wrapper for an awesome Docker CLI!
MIT License
557 stars 102 forks source link

Set `defer_build=True` pydantic config, improving import time significantly #643

Closed LewisGaul closed 1 week ago

LewisGaul commented 1 week ago

Partially addresses https://github.com/gabrieldemarmiesse/python-on-whales/issues/552. This config option is suggested in https://github.com/pydantic/pydantic/discussions/6748.

Before:

$time python -c "import python_on_whales"

real    0m0.405s
user    0m0.401s
sys     0m0.023s

After:

$time python -c "import python_on_whales"

real    0m0.206s
user    0m0.206s
sys     0m0.011s