Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Intro to FastAPI: Tips and Tricks for ML
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Sebastián Ramírez
April 13, 2023
Technology
1
360
Intro to FastAPI: Tips and Tricks for ML
Sebastián Ramírez
April 13, 2023
Tweet
Share
More Decks by Sebastián Ramírez
See All by Sebastián Ramírez
2025-10 PyCon Brasil keynote - Behind the scenes of FastAPI and friends for developers and builders
tiangolo
0
20
PyCon Taiwan Keynote - Behind the scenes of FastAPI and friends for developers and builders
tiangolo
0
170
Modern Python through FastAPI and friends - PyCon Sweden
tiangolo
0
62
Await for it: mixing async and blocking code - PyCon MEA - Dubai
tiangolo
0
36
Modern Python through FastAPI and friends - PyCon MEA - Dubai
tiangolo
0
880
CLI apps with Typer - Python type annotations and shell completion
tiangolo
0
390
Software de Colombia para el mundo
tiangolo
1
1.7k
Modern Python through FastAPI and friends - PyCon Indonesia
tiangolo
0
510
Modern Python through FastAPI and friends - Dubai - AI Everything - Gitex
tiangolo
0
120
Other Decks in Technology
See All in Technology
Werner Vogelsが14年間 問い続けてきたこと
yusukeshimizu
2
240
GitHub Copilot CLI 現状確認会議
torumakabe
12
4.9k
ドキュメントからはじめる未来のソフトウェア
pkshadeck
4
1.9k
AI開発の落とし穴 〜馬には乗ってみよAIには添うてみよ〜
sansantech
PRO
10
5k
AI開発をスケールさせるデータ中心の仕組みづくり
kzykmyzw
0
170
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
72k
プロダクトエンジニアこそ必要なPMスキル 〜デリバリー力を最大化し、価値を届け続けるために〜
layerx
PRO
0
150
Agentic Coding 実践ワークショップ
watany
41
27k
SREの仕事を自動化する際にやっておきたい5つのポイント
jacopen
6
1.1k
The Engineer with a Three-Year Cycle - 2
e99h2121
0
200
「AIでできますか?」から「Agentを作ってみました」へ ~「理論上わかる」と「やってみる」の隔たりを埋める方法
applism118
9
6.7k
【Oracle Cloud ウェビナー】[Oracle AI Database + Azure] AI-Ready データ戦略の最短ルート:Azure AIでビジネス データの価値を最大化
oracle4engineer
PRO
2
130
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
AI: The stuff that nobody shows you
jnunemaker
PRO
2
210
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
430
A better future with KSS
kneath
240
18k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Visualization
eitanlees
150
17k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
50
GitHub's CSS Performance
jonrohan
1032
470k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
280
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
100
Transcript
Intro to High performance, easy to learn, fast to code,
ready for production Tips and Tricks for ML
Who am I? Sebastián Ramírez github.com/tiangolo linkedin.com/in/tiangolo twitter.com/tiangolo tiangolo.com Berlin,
Germany I created:
• Python Web API framework • 50K+ GitHub stars (about
1K+ per month) • Used by Microsoft, Uber, Netflix, etc. • Performance in the top rank for Python • 3rd most used (Python Developers Survey) • Fastest growth (Python Developers Survey) • 3rd most loved (StackOverflow Developer Survey) @tiangolo
• OpenAPI • JSON Schema • OAuth2 🔄 Automatic data
conversion ✨ ✅ Automatic data validation ✨ FastAPI is based on standards 📝 Automatic API docs ✨ • Standard type annotations @tiangolo
Based on standards - for free @tiangolo
Based on Python type hints • Autocompletion everywhere • Type
checks and type errors @tiangolo
Types provide autocompletion @tiangolo
Easy and short @tiangolo
Less API code @tiangolo
Basic FastAPI app @tiangolo https://somedomain.com/items/5?q=some+query
Basic FastAPI app - docs @tiangolo https://somedomain.com/docs
Automatic docs @tiangolo
Basic FastAPI app with body @tiangolo
Basic FastAPI app with body - docs @tiangolo
Basic FastAPI app with body - docs @tiangolo
Basic FastAPI app with body @tiangolo
Basic FastAPI app with body and query @tiangolo
Basic FastAPI app with body and query - docs @tiangolo
https://somedomain.com/food/?delivery=true
Basic FastAPI app with body and query @tiangolo
JSON array of objects in body @tiangolo
JSON array of objects in body - docs @tiangolo
JSON array of objects in body @tiangolo
JSON array of objects in body - invalid data @tiangolo
JSON array of objects in body - validation @tiangolo
Data validation @tiangolo
FastAPI auto-completion @tiangolo
Type checks @tiangolo
All based on standard Python types @tiangolo
FastAPI - Performance @tiangolo
FastAPI - Performance @tiangolo
FastAPI - Other features @tiangolo • Dependency Injection • Security
- OAuth2 • WebSockets • Files • Background Tasks • Easy GraphQL integration • Templates • More...
Simple ML model and usage 🤖 @tiangolo
Load ML models - slow disk reads 🤖 @tiangolo ✨
Read from disk as few times as possible ✨
Load ML models - slow disk reads 🤖 @tiangolo
Simple ML model - only load 🤖 @tiangolo
ML model in FastAPI - simple - good ✅ @tiangolo
ML model in FastAPI - bad 🚨 @tiangolo
ML model in FastAPI - very bad 🚨 @tiangolo
ML model in FastAPI - very bad 🚨 @tiangolo
Load model and cache 😎 @tiangolo
FastAPI with cached model ⚡ @tiangolo
FastAPI with cached model ⚡ @tiangolo
FastAPI - preload cached model in healthcheck ⚡ @tiangolo
FastAPI - preload ⚡ @tiangolo
FastAPI - async and models - bad 🚨 @tiangolo
FastAPI - async and models - bad 🚨 @tiangolo
Blocking code in async blocks the event loop 😱 @tiangolo
✨ Don’t put blocking code directly in async functions ✨
FastAPI - non async and models - simple - good
✅ @tiangolo
FastAPI - non async and models - simple - good
✅ @tiangolo
FastAPI - async and models - good ✅ @tiangolo
FastAPI - async and models - good ✅ @tiangolo
FastAPI - model in dependency ✨ @tiangolo
FastAPI - model in dependency - testing ✅ @tiangolo
FastAPI - model in dependency - testing ✅ @tiangolo
FastAPI - squeeze performance 🚤 @tiangolo
FastAPI - squeeze performance 🚤 @tiangolo
None
Thank you! Sebastián Ramírez tiangolo.com fastapi.tiangolo.com github.com/tiangolo linkedin.com/in/tiangolo twitter.com/tiangolo