docs: add async usage tip for clarity

This commit is contained in:
Malak khoder 2025-12-14 22:21:12 +02:00
parent 0c2c0561f3
commit 5a57c67b8e
1 changed files with 3 additions and 0 deletions

View File

@ -178,6 +178,9 @@ def read_item(item_id: int, q: Union[str, None] = None):
<summary>Or use <code>async def</code>...</summary>
> **Tip:** Use `async def` when performing I/O-bound operations to fully benefit from FastAPI's asynchronous performance.
**Tip**: Use `async def` only when your code performs non-blocking I/O
(e.g. database calls, external APIs). For CPU-bound or blocking code,
prefer `def` to avoid performance issues.
```Python hl_lines="9 14"