Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃摑 Update docs for ORJSONResponse with details about improving performance #2615

Merged
merged 4 commits into from Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/en/docs/advanced/custom-response.md
Expand Up @@ -21,6 +21,8 @@ For example, if you are squeezing performance, you can install and use <a href="

Import the `Response` class (sub-class) you want to use and declare it in the *path operation decorator*.

For large responses, returning a `Response` directly is much faster than returning a dictionary and having FastAPI inspect every item inside. However, you be certain that the dictionary you pass to the Response is json serializable (or subclass the JSONResponse class and add your own custom serialization).
falkben marked this conversation as resolved.
Show resolved Hide resolved

```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial001b.py!}
```
Expand Down
2 changes: 1 addition & 1 deletion docs_src/custom_response/tutorial001b.py
Expand Up @@ -6,4 +6,4 @@

@app.get("/items/", response_class=ORJSONResponse)
async def read_items():
return [{"item_id": "Foo"}]
return ORJSONResponse([{"item_id": "Foo"}])