Stop using async def for everything in FastAPI. You’re likely killing your performance without realizing it. Just because you can make an endpoint asynchronous doesn't mean you should. If you call a blocking function (like a standard DB query or time.sleep) inside an async block, you freeze the entire Event Loop. Swipe through to see: When to use def vs async def. How the Event Loop vs. Thread Pool actually works.
Async vs Sync in FastAPI: Boost Performance
More Relevant Posts
-
Reactive schema debugging costs hours. A silently changed field can break a dashboard, mute an alert, or corrupt a compliance report long before anyone raises a flag. System Dataset engine.schema_fields gives you the full history of every field across every dataset, automatically. Baseline your schemas, detect drift on a schedule, and alert on the rate of change, not just the fact of it. Read the full breakdown here. 👇🏼 https://bit.ly/4tgMedn
To view or add a comment, sign in
-
-
Reactive schema debugging costs hours. A silently changed field can break a dashboard, mute an alert, or corrupt a compliance report long before anyone raises a flag. System Dataset engine.schema_fields gives you the full history of every field across every dataset, automatically. Baseline your schemas, detect drift on a schedule, and alert on the rate of change, not just the fact of it. Read the full breakdown here. 👇🏼 https://bit.ly/3PzXl2y
To view or add a comment, sign in
-
-
Reactive schema debugging costs hours. A silently changed field can break a dashboard, mute an alert, or corrupt a compliance report long before anyone raises a flag. System Dataset engine.schema_fields gives you the full history of every field across every dataset, automatically. Baseline your schemas, detect drift on a schedule, and alert on the rate of change, not just the fact of it. Read the full breakdown: https://bit.ly/4d5eWcu
To view or add a comment, sign in
-
-
Day 137 of my #365DaysOfDSA journey. Problem Summary: Given a binary string s, determine the minimum number of changes required to make the string alternating (no two adjacent characters are the same). An alternating string can follow two possible patterns: Pattern 1: 010101... Pattern 2: 101010... Approach: There are only two valid alternating patterns. Count the number of changes needed to convert the string into each pattern. The minimum of the two counts is the answer. To compute this: Assume the string starts with '0' and count mismatches. Assume the string starts with '1' and count mismatches. Return the smaller count. Algorithm Steps: Initialize two counters. Traverse the string from index 0 to n-1. For each index: Compare with expected value for pattern 0101.... Compare with expected value for pattern 1010.... Return the minimum mismatch count. Complexity Analysis: Time Complexity: O(n) Space Complexity: O(1) Status: Accepted Runtime: 0 ms Memory: ~9.5 MB Key Takeaway: When a problem has only two possible patterns, evaluate both and choose the optimal result. This simplifies many binary string problems. Day 137 completed.
To view or add a comment, sign in
-
-
skills are like prefix trees, agent harness by default provides limited just-in-time compute, by traversing the (precomputed) prefix tree, agent harness avoids exploring irrelevant branches and preserve compute for the node that matters
To view or add a comment, sign in
-
To get away from the need of maintaining multiple arrays, a single map of statistics is used which stores in it as a set of RTCStats objects. Read more 👉 https://bit.ly/4imMBgS #WebRTC
To view or add a comment, sign in
-
Stack vs Queue — same data, different behavior. 🤔 Stack: Last In → First Out. Like stacking plates 🍽️ — the last one you place is the first one you take. Queue: First In → First Out. Like standing in a line 🚶 — whoever comes first gets served first. Interesting how such simple rules power things like recursion stacks, scheduling, and BFS. Another small DSA concept that clicked while practicing today. 🧠 #DSA #Stack #Queue #JavaDeveloper #ProblemSolving
To view or add a comment, sign in
-
-
Day 85 Today’s challenge: 3548. Equal Sum Grid Partition II (Hard) This problem really pushed my understanding of prefix sums, hash maps, and grid partitioning logic. The goal was to determine whether we can split a grid into two parts with equal sums — either directly or by removing at most one element while keeping the section connected. 💡 Key Takeaways: Precomputing total sum is crucial before attempting splits Efficient tracking using hash maps helps avoid recomputation Handling edge cases (like removing one element) makes the problem significantly trickier Always think about both horizontal and vertical partitions ⚡ Result: ✅ All test cases passed (942/942) ⏱ Runtime: 1010 ms 💾 Memory: 443.52 MB This one wasn’t easy — but that’s where real growth happens. Consistency is starting to pay off. On to Day 86 🔥 #LeetCode #CodingJourney #Day85 #DSA #ProblemSolving #Consistency #KeepGrinding
To view or add a comment, sign in
-
-
Current LLMs generate code that loops way too much. If you need to get subsets of a Polars DataFrame, use partition_by build a dict of sub-dataframes. Just be aware that the dict keys are a tuple (1,) even for a single column partition
To view or add a comment, sign in
-
-
🚀Day 133 of my #365DaysOfDSA journey Today’s problem required swapping every two adjacent nodes in a linked list without modifying node values. 💡 Problem Insight The key restriction is: Swap nodes, not values Maintain proper links Handle edge cases (odd number of nodes) To simplify head handling, using a dummy node is extremely helpful. 🧠 Approach (Iterative with Dummy Node) Create a dummy node pointing to head Maintain: prev → node before the pair curr → first node of the pair While curr and curr->next exist: Identify second node Adjust pointers to swap the pair Move prev and curr forward This ensures clean swapping without breaking the list. ⚙️ Algorithm Steps Initialize dummy->next = head Set prev = dummy While curr && curr->next: second = curr->next curr->next = second->next second->next = curr prev->next = second Move prev = curr Move curr = curr->next Return dummy->next 📊 Complexity Analysis Time Complexity: O(n) Space Complexity: O(1) ✅ Status Accepted ✅ Runtime: 0 ms ⚡ Memory: ~11 MB 📦 ✨ Key Takeaway Whenever modifying linked list structure: Use a dummy node to simplify edge cases Carefully adjust pointers step-by-step Always preserve next references before rewiring Linked list problems are mostly about pointer discipline. 133 days completed 💪 #Day133 #365DaysOfDSA #LeetCode #LinkedList #PointerManipulation #CPlusPlus #Consistency #LearningInPublic
To view or add a comment, sign in
-