This commit is contained in:
saimahesh8752 2026-02-07 08:38:50 +00:00 committed by GitHub
commit 45e44d58d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -349,6 +349,11 @@ async def read_burgers():
return burgers
```
**Clarification on `async def` usage**
Using `async def` is beneficial primarily when the function performs I/O-bound work, such as awaiting network or disk operations (e.g. database calls, HTTP requests, or other non-blocking tasks). If a path operation function contains only blocking or CPU-bound code, defining it with `async def` does not provide performance benefits and may add unnecessary complexity. In such cases, using a regular `def` function is often simpler and clearer.
### More technical details { #more-technical-details }
You might have noticed that `await` can only be used inside of functions defined with `async def`.