How async/await turns 30 seconds into 3 seconds (without changing the server)? TL;DR: By letting the program handle multiple requests while waiting using async and await! What does AWAIT do? When code hits await, it tells Python: "This will take time, go do something else meanwhile." Python's event loop then switches to another task, keeping the CPU busy instead of idle. What's Actually Happening? -> async def marks a function as asynchronous -> await marks points where the program can pause and switch tasks Note that this works for I/O bound tasks only, CPU bound tasks need multiprocessing. Takeaway: -> async/await is perfect for I/O bound concurrent operations -> 10x performance improvements are common -> The learning curve is worth it for any I/O-heavy application I'm diving deep into Python concurrency. Follow along and share your bottleneck stories in comments! #Python #Concurrency #SoftwareEngineering #BackendDevelopment #Performance
Onkar Lapate’s Post
More Relevant Posts
-
😵 Thread-local storage works great... until you move to async. Then the weird stuff starts. Request IDs bleeding between coroutines. Background tasks sharing state. “Random” bugs that disappear under logging. Sound familiar? Async doesn’t care about threads. It cares about execution context. In my latest article I explain: 🔍 Why threading.local() fails under asyncio 🧠 How ContextVars isolate state per coroutine ⚙️ Real examples with async tasks and request-scoped data 👉 https://lnkd.in/d_aVTDtW #python #softwaredevelopment #backend #engineering #asyncio
To view or add a comment, sign in
-
Rembus Introduces Async-first RPC and Pub/Sub with Synchronous Python API 📌 Rembus introduces a lightweight, async-first messaging system for Python that seamlessly blends RPC and Pub/Sub with a simple synchronous API-perfect for edge and embedded applications. Built with CBOR for speed and DuckDB for persistent, ACID-compliant storage, it enables real-time DataFrame sharing and hierarchical topic routing, all without heavy infrastructure. 🔗 Read more: https://lnkd.in/dF9JHama #Rembus #Python #Rpc #Pubsub #Asyncfirst
To view or add a comment, sign in
-
That `InitVar` in a dataclass… do you actually know what it does? It looks like a field. It’s declared like a field. But it’s not really a field. In today’s video, I walk through 7 interesting things you can do with Python dataclasses. From automatic class registration and lightweight validation systems to cached derived values, self-building CLI parsers, and even using dataclasses as context managers. Most developers treat dataclasses like “nicer structs.” But they’re just normal Python classes with less boilerplate. And once you realize that, they become a design tool, not just a convenience. 👉 Watch the full video here: https://lnkd.in/eeEzkhJQ. #python #dataclasses #softwaredesign #cleancode #developers #arjancodes
To view or add a comment, sign in
-
-
#Day 47 of My Python & DSA Journey Today I solved the “Check if Binary String Has at Most One Segment of Ones” problem on LeetCode. 🔍 Problem Overview: Given a binary string containing only 0s and 1s, the task is to determine whether the string contains at most one continuous segment of 1s. If multiple separated segments of 1s exist, the result should be False. 🧠 Approach: I iterated through the string and tracked how many times a new segment of 1s starts. Whenever a 1 appears either at the beginning of the string or immediately after a 0, it indicates the start of a new segment. If more than one such segment is found, the condition fails. ⚡ Key Takeaways: • Strengthened understanding of string traversal • Practiced pattern recognition in binary strings • Improved logical problem-solving using Python 📊 Complexity: • Time Complexity: O(n) • Space Complexity: O(1) Consistently solving problems helps me improve my algorithmic thinking and coding efficiency every day. Looking forward to learning more and solving tougher challenges ahead! Under the Guidance of : Rudra Sravan kumar and Manoj Kumar Reddy Parlapalli #Day47 #Python #LeetCode #DataStructures #Algorithms #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
That `InitVar` in a dataclass… do you actually know what it does? It looks like a field. It’s declared like a field. But it’s not really a field. In today’s video, I walk through 7 interesting things you can do with Python dataclasses. From automatic class registration and lightweight validation systems to cached derived values, self-building CLI parsers, and even using dataclasses as context managers. Most developers treat dataclasses like “nicer structs.” But they’re just normal Python classes with less boilerplate. And once you realize that, they become a design tool, not just a convenience. 👉 Watch the full video here: https://lnkd.in/e5pkc7Ae. #python #dataclasses #softwaredesign #cleancode #developers #arjancodes
To view or add a comment, sign in
-
-
🐍 𝗠𝘆𝘁𝗵 𝘃𝘀 𝗥𝗲𝗮𝗹𝗶𝘁𝘆: 𝗣𝘆𝘁𝗵𝗼𝗻 𝗶𝘀 “𝘁𝗼𝗼 𝘀𝗹𝗼𝘄” 𝘁𝗼 𝗯𝗲 𝘂𝘀𝗲𝗳𝘂𝗹 Myth: Python is slow, so it shouldn’t be used for serious systems. Reality: Python powers some of the biggest platforms today. It’s widely used for: 🤖 Artificial Intelligence 📊 Data Science 🌐 Web Applications ⚙️ Automation Why? Because **developer productivity often matters more than raw speed.** Critical performance parts can always be written in C/C++ underneath. 𝗧𝗵𝗲 𝗿𝗶𝗴𝗵𝘁 𝘁𝗼𝗼𝗹 𝗶𝘀𝗻’𝘁 𝗮𝗹𝘄𝗮𝘆𝘀 𝘁𝗵𝗲 𝗳𝗮𝘀𝘁𝗲𝘀𝘁 𝗼𝗻𝗲. #Python #Programming #LearningInPublic #ITStudent
To view or add a comment, sign in
-
-
The Async Performance Paradox ⚡ Performance tuning isn't always about writing 'faster' code; it's about picking the right concurrency model. 🏎️ In Python, switching from synchronous Gunicorn workers to an asynchronous ASGI setup like Uvicorn can drastically reduce latency for I/O-bound tasks. 📉 Understanding when to use asyncio vs. multi-threading is the key to scaling distributed systems without exploding your infrastructure costs. 💰🚀 #Python #BackendEngineering #PerformanceTuning #AsyncIO #SoftwareEngineering #Scalability #SystemDesign #CloudComputing
To view or add a comment, sign in
-
-
You don’t always need async to get concurrency in Python. Async is powerful, but it has a problem: it needs async-compatible libraries for everything. TL;DR: Threading works with regular blocking libraries - no async migration needed! Threading solves the same I/O bound problem as async, but works with regular blocking libraries too. How It Works? 1. Instead of one event loop switching between tasks, threading creates multiple OS threads. 2. Each thread can make blocking calls independently. When one thread waits for I/O, others keep running. Where Threading Wins? -> Working with libraries that don't have async versions -> Existing codebase with blocking code Threading and async give similar performance for I/O bound tasks! Trade off - Threads have more overhead than async coroutines. For thousands of concurrent operations, async is lighter. I'm diving deep into Python concurrency. Follow along and share your bottleneck stories in comments! #Python #Concurrency #SoftwareEngineering #BackendDevelopment #Performance
To view or add a comment, sign in
-
We built a Python library that makes LLM responses type-safe and tracks token costs automatically. YALC (Yet Another LLM Client) gives you one unified interface — structured Pydantic outputs, token tracking, and cost monitoring across providers. Get more information on our blog post below. 📖 Blog: https://lnkd.in/dvf4vThk ⭐ GitHub: https://lnkd.in/dZeny3X5 #Python #AI #LLM #OpenSource
To view or add a comment, sign in
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
Whats the difference in using async vs threadpoolexecutor