How the asyncio event loop actually works? TL;DR: It's a loop that checks: "Which tasks are ready to run right now?" The Event Loop keeps doing the following - 1. Check which tasks are ready 2. Run one task until it hits 'await' 3. Task pauses, switch to next ready task 4. Repeat What Happens code hits await some_operation()? -> Task says: "I'm waiting for I/O" -> Event loop skips it, runs another task -> When I/O completes, task becomes ready again -> Loop picks it up and resumes Catch - Event loop runs in one thread. This is why blocking calls freeze everything. I’m deep-diving into Python internals and performance. Do follow along and tell your experiences in comments. #Python #PythonInternals #SoftwareEngineering #BackendDevelopment #Asyncio
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
-
Just practiced Pandas and data cleaning hits different when you're working with real messy data. Covered data types, type conversion, handling missing values, replacing inconsistent entries, and using category dtype to save memory — FuelType column went from 11488 bytes to 1460 bytes just by changing the dtype. Notebook here 👉 https://lnkd.in/d3djYPvp #Python #Pandas #DataAnalysis #LearningInPublic
To view or add a comment, sign in
-
Ask your agent to delete a database. And it will. No questions asked. That's terrifying. Two gates fix it. One checks the input before the agent runs. One checks the output before you see it. Each gate is a list of functions. Adding a rule? One more line. "drop all tables" → blocked. Before it even starts. Answer mentions a password → redacted. Before you see it. Same agent. Now with boundaries. Checkout the video. Day 7 of 9. https://lnkd.in/gQZQWy4D #AIAgents #AISafety #BuildInPublic #Python
To view or add a comment, sign in
-
Understanding how data structures behave is crucial for writing reliable and scalable Python code. In my latest article, I explore the real difference between Lists and Tuples in Python and why choosing the right one can impact system stability, performance, and trust in real-world applications. From flexibility to stability, this article explains when data should evolve and when it must remain unchanged. Read the full article here: https://lnkd.in/gvQahst3 #Python #DataScience #Programming #Coding #PythonProgramming #SoftwareEngineering #TechLearning #Developers #DataEngineering #Analytics #MachineLearning #AI #TechCommunity #LearnToCode #CareerGrowth
To view or add a comment, sign in
-
Didn't know you could extract tables from a Word doc using Python until today. python-docx lets you loop through tables, pull cell data, and load it straight into a DataFrame. Spent some time cleaning it up — splitting on ':', transposing, fixing headers — but it worked. Also practiced groupby() and lambda functions inline. Small things but they make the code so much cleaner. Notebook here 👉 https://lnkd.in/dfTwrvqT #Python #Pandas #DataAnalysis #LearningInPublic
To view or add a comment, sign in
-
Practiced Python functions today — *args, **kwargs, return types, and function types. The one thing that clicked — *args is for unknown number of values (stores as tuple), **kwargs is when you don't know the keys either (stores as dict). Simple but I was mixing them up before. Also learned there are actual types of functions — action, transformation, validation. https://lnkd.in/ducSzXzK #Python #LearningInPublic #DataAnalysis
To view or add a comment, sign in
-
Day 54 of 365 Days of code 1) Capacity to Ship Packages Within D Days Approach: Binary search 1)set low = max(weights) 2) high= low*sum(weights) 3) perform the below steps until low<=high condition fails i) mid=low+(high-low)//2;res=0 ii) set w = mid and initialize day=1 iii) iterate through the loop and perform the stuff i put in screenshot (ahh life hurts :") ) iv) if the day <= days: set res=mid ; set high=mid-1 v) else low=mid+1 4) return res #365daysOfCode #NeetCode #leetcode #DSA #python #LeetCode #ProblemSolving #Algorithms #365dayschallenge
To view or add a comment, sign in
-
-
Scale vector search to millions without rewriting your prototype code ⚡ Building semantic search typically starts with storing vectors in Python lists and computing cosine similarity manually. But brute-force comparison scales linearly with your dataset, making every query slower as your data grows. Qdrant is a vector search engine built in Rust that indexes your vectors for fast retrieval. Key features: • In-memory mode for local prototyping with no server setup • Seamlessly scale to millions of vectors in production with the same Python API • Built-in support for cosine, dot product, and Euclidean distance • Sub-second query times even for millions of vectors ☕️ Run this code: https://bit.ly/4cCI76w #VectorDatabase #Python #SemanticSearch #DataScience
To view or add a comment, sign in
-
-
INSTEAD OF WASTING TIME AND TRYING TO GET FIGURES. WHY NOT USING CODE?? Sometimes, lecturers or organizations need to generate different sets of questions for multiple candidates, especially when working with matrices. However, this often requires a lot of manual effort and can be time-consuming. Why not simplify the process using NumPy in Python? With just a few lines of code, you can easily generate multiple variations of matrix-based questions efficiently and save valuable time. #randint is an inbuilt function of the random module of numpy #Syntax: np.random.randint(start, stop (rows, columns)) a=np.random.randint(2,30, (3,3)) b=np.random.randint(2,30, (3,3)) c=np.random.randint(2,30, (3,3)) d=np.random.randint(2,30, (3,3)) e=np.random.randint(2,30, (3,3)) #DataScience #Python #NumPy #Education #Automation
To view or add a comment, sign in
-
-
A teammate recently ran into this Pandas error: TypeError: argument of type 'float' is not iterable The code looked correct: df.query("Overseas Collection in Crores == 0") The issue? The column name had spaces. query() evaluates the condition as a Python expression. Because the column name contained the word in, Pandas interpreted it as the membership operator. The Fix: df.query("`Overseas Collection in Crores` == 0") Or: df[df["Overseas Collection in Crores"] == 0] Clean column naming conventions help prevent subtle bugs. #Python #Pandas #DataEngineering
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