Performance: Environment-based settings
MEDIUM IMPACT
This concept affects the app startup time and runtime configuration loading, impacting initial response speed and stability.
from pydantic import BaseSettings class Settings(BaseSettings): debug: bool = False database_url: str class Config: env_file = '.env' settings = Settings()
import os class Settings: DEBUG = os.getenv('DEBUG', 'false').lower() == 'true' DATABASE_URL = os.getenv('DATABASE_URL') settings = Settings()
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct os.getenv calls multiple times | 0 | 0 | 0 | [X] Bad |
| Pydantic BaseSettings single load | 0 | 0 | 0 | [OK] Good |