Performance: Route decorator syntax
MEDIUM IMPACT
This affects the server-side routing setup which indirectly impacts initial response time and client perceived load speed.
from fastapi import FastAPI app = FastAPI() @app.get('/items/{item_id}') async def read_item(item_id: int): # delegate complex logic to async functions result = await fetch_item_data(item_id) return result
from fastapi import FastAPI app = FastAPI() @app.get('/items/{item_id}') def read_item(item_id: int): # complex logic inside route return {'item_id': item_id}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous blocking route handler | 0 | 0 | 0 | [X] Bad |
| Async non-blocking route handler | 0 | 0 | 0 | [OK] Good |