FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

✨ Serialize JSON response with Pydantic (in Rust), when there's a Pydantic return type or response model by tiangolo · Pull Request #14962 · fastapi/fastapi · GitHub

Repository navigation

✨ Serialize JSON response with Pydantic (in Rust), when there's a Pydantic return type or response model - #14962

Merged
tiangolo merged 7 commits into
masterfrom
serialize-pydantic
Feb 22, 2026
Merged

tiangolo merged 7 commits into
masterfrom
serialize-pydantic

Conversation

Copy link
Copy Markdown
Member

✨ Serialize JSON response with Pydantic (in Rust), when there's a Pydantic return type or response model

tiangolo added the feature New feature or request label Feb 22, 2026

codspeed Bot commented Feb 22, 2026 •
edited
Loading

Copy link
Copy Markdown

Merging this PR will improve performance by ×2.1

⚡ 4 improved benchmarks
✅ 16 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_sync_return_large_dict_with_response_model 13.2 ms 7 ms +88.26%
⚡ test_sync_return_large_model_with_response_model 13.3 ms 7.1 ms +89.05%
⚡ test_async_return_large_dict_with_response_model 11.7 ms 5.6 ms ×2.1
⚡ test_async_return_large_model_with_response_model 11.8 ms 5.6 ms ×2.1

Comparing serialize-pydantic (880ad19) with master (1e78a36)

github-actions Bot commented Feb 22, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

tiangolo changed the title ✨ Serialize JSON response in Rust, with Pydantic, when there's a Pydantic return type or response model ✨ Serialize JSON response with Pydantic (in Rust), when there's a Pydantic return type or response model Feb 22, 2026
tiangolo marked this pull request as ready for review February 22, 2026 16:05
tiangolo merged commit 590a5e5 into master Feb 22, 2026
39 checks passed
tiangolo deleted the serialize-pydantic branch February 22, 2026 16:07

Copy link
Copy Markdown

A bit stupid question maybe, but If I was already returning pydantic model and response model was that model, I will still get performance boost?

Copy link
Copy Markdown
Member Author

Yes, you will 🚀

Copy link
Copy Markdown

@tiangolo currently we are using response_model will it also performance improvement ?

@router.get("/sample", response_model=Sample)
def sample_endpoint(
    *,
    db: Session = Depends(deps.get_db),
    store_id: int,
    user_id: Optional[int] = None,
):

Copy link
Copy Markdown

@pmsmanishchauhan Yes it will

tiangolo added a commit that referenced this pull request Feb 23, 2026
…'s a Pydantic return type or response model (#14962)"

This reverts commit 590a5e5.

Copy link
Copy Markdown
Contributor

Same but for parsing HTTP body: #13951

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL