Performance: Configuration management
MEDIUM IMPACT
This affects the startup time and runtime efficiency of the FastAPI app by managing how configuration data is loaded and accessed.
from fastapi import FastAPI import json app = FastAPI() with open('config.json') as f: config = json.load(f) @app.get('/') async def root(): return {"message": config['welcome_message']}
from fastapi import FastAPI import json app = FastAPI() def get_config(): with open('config.json') as f: return json.load(f) @app.get('/') async def root(): config = get_config() return {"message": config['welcome_message']}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Load config per request | N/A | N/A | Blocks server response causing delayed paint | [X] Bad |
| Load config once at startup | N/A | N/A | Fast server response enables quicker paint | [OK] Good |