Been deep in a FastAPI backend project and something bugged me — the code I was writing looked different from the official docs. So I dug into it. Turns out FastAPI pushed some massive updates recently; 1. Python 3.9 support? Gone. Pydantic v1? Gone. The entire documentation was rewritten for Python 3.10+ syntax. What used to be: from typing import Optional name: Optional[str] = None Is now just: name: str | None = None Cleaner. No imports needed. 2. .dict() became .model_dump(). 3. .from_orm() became .model_validate(). 4. JSON responses got 2x faster automatically through Pydantic's Rust serializer. 5. They added native streaming with yield — perfect for AI applications. Spent tonight updating 12 files across my project. Every old pattern eliminated. Lesson: documentation changes. Check the release notes regularly. What you learned 6 months ago might have a newer, better way now. #FastAPI #Python #BackendDevelopment #WebDev
FastAPI Updates: Python 3.9 Support & Documentation Changes
More Relevant Posts
-
Okay I'm long overdue a post, so let's fix that. I built a YouTube video summarizer and actually shipped it — paste in any URL (long-form or Shorts) and it gives you a structured summary: Overview, Key Points, and Conclusion. No watching required. 𝐓𝐡𝐞 𝐬𝐭𝐚𝐜𝐤: Python + FastAPI for the backend Supadata to pull transcripts from YouTube Groq (Llama 3.3 70B) for the AI summaries Hosted on Render Live demo: https://lnkd.in/g8jFDmX3 Source code: https://lnkd.in/gA6Hin-D (hosted on Render's free tier — if it takes a minute to load, just hang tight, it's spinning up) This is also the start of something I'm committing to: 𝐨𝐧𝐞 𝐩𝐫𝐨𝐣𝐞𝐜𝐭 𝐞𝐯𝐞𝐫𝐲 𝐰𝐞𝐞𝐤, shipped and posted publicly. Each one will be open source — if you want to contribute, PRs are open and I review everything that goes in. Follow along, contribute, or just check out the repo. Would love to connect with people building things too. #buildinpublic #python #ai #opensource #softwareengineering
To view or add a comment, sign in
-
-
I thought FastAPI was fast. Turns out I was just using it wrong. Client called me one day. Why is the API so slow? I thought you said FastAPI is fast? I said yes. FastAPI is async. It handles concurrent requests beautifully. What I didn't say.... My routes weren't async at all. Here's what my code looked like: # What I wrote @app.get("/users/{id}") def get_user(id: int, db: Session = Depends(get_db)): return db.query(User).filter(User.id == id).first() Looks fine right? That def instead of async def — that one word was blocking FastAPI's entire event loop. Every request was waiting for the previous one to finish. Not concurrent. Not async. Just a very expensive queue. The fix was literally one word: # What it should have been @app.get("/users/{id}") async def get_user(id: int, db: AsyncSession = Depends(get_db)): result = await db.execute(select(User).where(User.id == id)) return result.scalars().first() def → async def Response time under load: 4 seconds → 200ms. The lesson nobody tells you clearly: FastAPI is only as async as you make it. The framework won't save you from blocking code. It just gives you the tools — you still have to use them correctly. → Always use async def for route handlers → Use httpx not requests inside async endpoints → Use AsyncSession not Session for DB calls One word. One month of slow APIs. One very unhappy client. #FastAPI #Python #BackendDevelopment #AsyncProgramming #SoftwareEngineering #LessonsLearned #WebDevelopment
To view or add a comment, sign in
-
🚀 Building Scalable APIs with FastAPI! ⚡ I’ve been exploring FastAPI, and I’m impressed by how fast and efficient it is for building high-performance Python APIs. Here’s a quick look at a simple yet powerful backend setup I built. This script demonstrates how to handle basic GET requests, dynamic path parameters, and simple arithmetic logic—all with automatic data validation! 🔍 What's happening in this code? • Root Endpoint: A simple health check to ensure the backend is running. • Personalized Greeting: Demonstrating how to capture string parameters from the URL. • Math Logic: A dynamic route that takes two integers, performs an addition, and returns the result as a JSON response. FastAPI is becoming my go-to for modern web development because of its speed, ease of use, and built-in support for asynchronous programming. 💻✨ 🌐 Check out my latest work: You can find more of my projects, experiments, and full-stack solutions on my portfolio: 🔗 https://lnkd.in/gWsGGTA2 #Python #FastAPI #BackendDevelopment #WebDevelopment #CodingLife #APIDevelopment #SoftwareEngineering #TechInnovation
To view or add a comment, sign in
-
-
This week, I built my first backend API using FastAPI I created a simple “Books API” to understand how backend systems handle requests and data. Built using Python + FastAPI, focusing on RESTful design principles. Here’s what I implemented: • GET → retrieve all books • Dynamic routes → fetch books by author • Query parameters → filter by category • POST → add new books • PUT → update existing books • DELETE → remove books One thing that stood out while building this: Even small mistakes (like JSON formatting or route handling) can completely change how an API behaves, debugging is a big part of backend development. Screenshots: Image 1 – FastAPI Books API implementation showing CRUD endpoints (GET, POST, PUT, DELETE) and route handling logic for managing book data. #FastAPI #BackendDevelopment #Python #SoftwareEngineering #LearningInPublic #APIs #TechStudent
To view or add a comment, sign in
-
-
In last post I talked about a problem I faced. Setting up a RAG pipeline was way harder than it should be. So here's the idea I came up with. 💡 What if there was a Python library that: → Takes any PDF or TXT file as input → Automatically chunks the document → Embeds it using FREE HuggingFace models → Stores it in a vector index → Lets you query it in plain English All of this. In 5 lines of code. No OpenAI key. No complex setup. No 200-page documentation. Just: ```python from ragkitpy import RAGPipeline rag = RAGPipeline() rag.load_document("my_file.pdf") results = rag.query("What is this document about?") ``` That's it. That's the whole idea. I'm calling it → ragkitpy 🚀 A lightweight, beginner-friendly RAG toolkit powered entirely by HuggingFace open-source models. No subscriptions. No API bills. Just pure Python. The best part? I'm building this as a complete beginner to open source. No senior guiding me. No company project backing it. Just curiosity, Google, and a lot of pytest runs. 😄 Next post → I'll break down how existing tools work and exactly where ragkitpy fits in. --- Follow along if you're curious about RAG, open source, or just love seeing someone figure things out in public. 🙌 #GenAI #RAG #OpenSource #Python #HuggingFace #BuildingInPublic #ragkitpy #AIEngineer #100DaysOfCode
To view or add a comment, sign in
-
-
While transforming my API from synchronous to asynchronous, I ran into an error: author Input should be a valid dictionary or instance of UserOut While debugging the issue, I discovered something interesting — it was related to lazy loading in SQLAlchemy. By default, relationships in SQLAlchemy are lazy-loaded, meaning related objects like author or comments are not fetched until they are accessed. When my Pydantic schemas tried to serialize the response, it threw an error because those related objects had not been accessed or loaded yet. This error pushed me to explore more about lazy loading and eager loading. Lazy loading fetches only the main object in the initial query, while eager loading fetches the related objects as well. During this process, I also learned about the N+1 query problem and how loading strategies can impact an API’s performance. I resolved the issue by using selectinload() in my query, although joinedload() can also be used depending on the situation. What started as a confusing error ended up becoming a great learning experience about how ORMs fetch data and why controlling loading strategies is important when building APIs. #FastAPI #Python #BackendDevelopment
To view or add a comment, sign in
-
Lately I’ve been exploring FastAPI and Python as a way to build and ship backend services faster, especially when experimenting with MVP ideas. To get a better feel for the framework, I built an event management API that supports features like authentication, event creation, and an RSVP system for users to interact with upcoming events. I also integrated a few supporting services to make the project feel closer to a real-world backend: • Image uploads handled through Cloudinary • Email notifications using SMTP • Containerised with Docker for a consistent development setup What I’ve enjoyed about working with FastAPI so far is how lightweight and fast it feels while still allowing you to structure APIs cleanly. Still experimenting and learning more about where it fits best in the kinds of systems I like building. If you’ve worked with FastAPI or Python for backend services, I’d be interested to hear about your experience with it. #FastAPI #Python #BackendDevelopment #Docker #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 DSA Day — Merge Two Sorted Arrays (LeetCode 88) Today I worked on a classic problem that looks simple but teaches an important optimization technique 👇 🔹 Problem Statement You are given two sorted arrays and need to merge them into one sorted array in-place. Example: nums1 = [1, 7, 8, 0, 0, 0], m = 3 nums2 = [2, 5, 6], n = 3 ✅ Output: [1, 2, 5, 6, 7, 8] 🔸 Approach 1: Brute Force ✔ Copy nums2 into nums1 ✔ Sort the entire array ⏱ Time Complexity: O((m+n) log(m+n)) 👉 Simple but not efficient 🔸 Approach 2: Optimized (Two Pointers) 💡 Key Idea: Start filling from the end ✔ Compare last elements of both arrays ✔ Place the larger one at the end ✔ Move pointers accordingly ⏱ Time Complexity: O(m+n) 📦 Space Complexity: O(1) 🔥 Why this works? Because nums1 already has extra space at the end — we use it smartly without shifting elements. 💻 Code Snippet (Optimized) https://lnkd.in/g9Z7yf3d def merge(nums1, m, nums2, n): i = m - 1 j = n - 1 k = m + n - 1 while i >= 0 and j >= 0: if nums1[i] > nums2[j]: nums1[k] = nums1[i] i -= 1 else: nums1[k] = nums2[j] j -= 1 k -= 1 while j >= 0: nums1[k] = nums2[j] j -= 1 k -= 1 🎯 Key Takeaway 👉 Always think from the end when dealing with in-place array problems. #DSA #Python #CodingInterview #LeetCode #ProblemSolving #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
-
Just solved LeetCode 862: Shortest Subarray with Sum at Least K If you've ever been trapped by a sliding window that just won't slide right, this one is for you! 👇 The Brute Force (O(N²)) The most intuitive approach is to calculate the prefix sum of the array, and then use a nested loop to check the sum of every possible subarray, keeping track of the shortest one that is >= K. The problem? The array length can be up to 10⁵. An O(N²) solution will immediately hit a Time Limit Exceeded (TLE). We need O(N). Normally, to find a shortest/longest subarray, we reach for the Sliding Window technique. But there's a catch: The array contains negative numbers. Because of negative numbers, our prefix sum is NOT monotonically increasing. The standard sliding window is completely broken here. To fix this, we need a way to track prefix sums intelligently. We can use a Double-Ended Queue (Deque) to store tuples of (prefix_sum, index) and force it to be strictly increasing (monotonic). Shrinking the window: As we iterate, we check if current_sum - smallest_prefix_sum_in_deque >= K. If it is, we found a valid subarray! We record the length, and throw away that starting index (pop left). Why? Because any future subarray using that start index would only be longer and therefore worse. Maintaining Monotonicity (Pop Right): What if our current_sum dips and is smaller than the most recent prefix sums in our deque? We can keep popping the back of queue as the older greater prefix sums work but make the subarray longer. This approach has a time complexity of O(n) and a space complexity of O(n) as well as in the worst case, the queue may contain n prefix sum where n: number of elements in the array. #LeetCode #Python #Algorithms #DataStructures #SoftwareEngineering #ProblemSolving #CodingInterviews
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development