Performance: Async path operations
HIGH IMPACT
This affects server response time and how quickly the browser receives data, impacting page load speed and interaction responsiveness.
from fastapi import FastAPI import asyncio app = FastAPI() @app.get("/data") async def get_data(): await asyncio.sleep(2) # non-blocking sleep return {"message": "Data fetched"}
from fastapi import FastAPI app = FastAPI() @app.get("/data") def get_data(): import time time.sleep(2) # blocking sleep return {"message": "Data fetched"}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous blocking path operation | N/A | N/A | Delays response, increasing INP | [X] Bad |
| Async non-blocking path operation | N/A | N/A | Faster response, better INP | [OK] Good |