If your Python scripts are making 50 API calls, synchronous code spends most of its time waiting around doing absolutely nothing. Suresh Vina has written an intro to async Python using a simple analogy: boiling a kettle and making toast at the same time. Sync code does one, then the other. Async runs both concurrently. Same two tasks: 5 seconds sync, 3 seconds async. It’s not a big deal when making breakfast. But scale that concept across dozens of API calls and the difference adds up. The Infrahub Python SDK supports both sync and async natively. Switching between them is simple. Suresh walks through the core concepts, shows side-by-side code examples, and builds up to running the same operation across multiple sites concurrently. If async Python has been sitting on your "I should learn that someday" list, now’s your chance to *get up to speed*. (See what we did there? 😉) Link in comments 👇
OpsMill’s Post
More Relevant Posts
-
Sometimes it is useful to go one layer lower than Python. A while ago Nikita showed a simplified print implemented through a direct syscall path to explain what actually happens under the hood: arguments, string representation, buffer length, registers, and then the call into the OS. This is not about rewriting Python in assembly. It is about something more practical: when you understand where the abstraction ends, you make better decisions higher up the stack too. In complex Python systems, many expensive problems start exactly there: - too many layers nobody questions anymore - hidden cost behind “convenient” abstractions - weak understanding of I/O boundaries - performance discussions without a clear model of what the system is actually doing You do not need assembly to build a good backend. But when someone can reason from Python code down to the runtime and OS boundary, they usually see architecture risks earlier than others do. That is one of the reasons architecture reviews are useful: they are not just about code style or framework choices. They are about understanding where the system becomes expensive to change, hard to trust, or harder to scale than it should be.
To view or add a comment, sign in
-
Async IO in Python is single-threaded. No mutexes, no race conditions, no surprise context switches. Coming from multi-threaded code, this felt like cheating. With threads, anything can interrupt anything. You lock shared state, hope you got it right, and debug it six months later when you didn't. With async, control only transfers at await. That's it. Your data is safe between those points by definition, not by luck. The payoff was immediate. Refactored a GitHub API client to fetch a user profile and repo list at the same time using asyncio.gather(). Two concurrent HTTP calls. No threads, no locks. The mental model shift took longer than the code change. If you've been avoiding async because threads burned you before, it's not the same thing.
To view or add a comment, sign in
-
Just wrote about something I kept running into in real backend work — using Enums instead of plain dictionaries for fixed states like booking status, event types, and error codes. Nothing fancy. Just a pattern that reduced silent bugs and made the code easier to read and refactor. Read here: https://lnkd.in/gnYwTtzU #Python #BackendDevelopment #SoftwareEngineering #PythonTips #CleanCode #APIDesign #PythonDeveloper #CodeQuality #Programming #TechArticle
To view or add a comment, sign in
-
Many Python I/O tutorials end at print() and open(). This one goes further. On PythonCodeCrack there's a full beginner tutorial on Python I/O that covers the ground many skip — not just how to use the tools, but why they work the way they do. What's inside: — stdin, stdout, and stderr: what they are, where they come from, and why Python didn't invent them — print() in full: sep, end, flush, and why flush=True doesn't mean your data is on disk — input() and why it always returns a string no matter what the user types — File modes r, w, a, and x — including why 'w' truncates before the first write, not during it — The three-layer CPython I/O stack (TextIOWrapper → BufferedWriter → FileIO) and how to inspect it live — PEP 393: why a single emoji in a 2 GB text file can force 4 bytes per character across the entire string — buffering=1 line-buffered mode for crash-safe log files — flush() vs os.fsync() — two entirely different operations that most tutorials treat as the same thing — Python 3.15 making UTF-8 the default on all platforms, and what that means for existing code — sys.__stdout__ vs sys.stdout, newline translation, file descriptors, and TOCTOU race conditions The tutorial includes interactive quizzes, spot-the-bug challenges, a code builder, predict-the-output exercises, a 15-question final exam, and a downloadable certificate of completion. https://lnkd.in/gbYPmYgv #Python #PythonProgramming #LearnPython #CodingEducation
To view or add a comment, sign in
-
Day 12/365: Checking If a List Is a Palindrome in Python 🔁 Today I solved a classic problem in Python: checking whether a list is a palindrome or not — using the two‑pointer technique with a for-else loop. 🔍 How this works step by step: I start with a list l that has elements arranged symmetrically. To check if it’s a palindrome, I compare elements from both ends: l[0] with l[-1], l[1] with l[-2], and so on. I only need to go till the middle of the list: range(len(l)//2) Inside the loop: If any pair doesn’t match, I print "list is not palindrome" and use break to exit the loop early. The interesting part is the for-else: The else block runs only if the loop finishes without hitting a break. That means all pairs matched, so I print "list is palindrome". 💡 What I learned: How to use the two‑pointer technique to compare elements from start and end efficiently. How Python’s for-else works — the else is tied to the loop, not the if. Why we only need to iterate till the middle of the list for palindrome checking. How the same logic can be reused for: checking if a string is a palindrome, validating symmetric data in lists and arrays. Day 12 done ✅ 353 more to go. If you have ideas like: checking palindromes while ignoring cases/spaces in strings, handling mixed data types in lists, or checking palindromes in other data structures, drop them in the comments — I’d love to try them next. #100DaysOfCode #365DaysOfCode #Python #LogicBuilding #TwoPointers #Lists #CodingJourney #LearnInPublic #AspiringDeveloper
To view or add a comment, sign in
-
-
One thing that significantly improved my Python code quality: Static analysis is not optional at scale. For a long time, I relied on code reviews to catch issues. Eventually, I realized something: 👉 Humans are bad at consistently spotting patterns. 👉 Tools are not. That’s where static analysis changed everything. Without running the code, these tools analyze your source and detect: bugs code smells complexity issues type inconsistencies All before production The combination that worked best for me: Ruff → fast linting and code quality Replaces multiple tools (flake8, isort, etc.) and runs extremely fast Mypy → type checking Uses type hints to catch bugs before runtime, bringing discipline to Python’s dynamic nature Radon → complexity analysis Measures cyclomatic complexity and highlights functions that are hard to maintain. #Python #StaticAnalysis #BackendEngineering #Django #CleanCode #SoftwareEngineering #DevOps
To view or add a comment, sign in
-
-
THE BEST WAY TO LEARN PYTHON ISN'T WATCHING VIDEOS. IT'S RUNNING THE CODE YOURSELF learn-python is a playground and cheatsheet in one repo every topic operators, data types, functions, classes, exceptions, file handling, standard libraries has real working scripts with code examples, inline comments, and assertions that show you the expected output right away you don't just read it. you run it, break it, change it, and test it https://lnkd.in/gZCT3EEK variables, loops, decorators, generators, lambda expressions, OOP all covered, all runnable
To view or add a comment, sign in
-
-
Most Python code looks simple until you realize how much is happening under the surface. Take this for example: _C = (1, 2, 3) a, b, c = _C print(a) This is iterable unpacking, more precisely Python’s way of doing positional destructuring assignment. What actually happens: _C is evaluated as an iterable Python matches elements positionally Each value is bound in a single atomic assignment step So internally: a = _C[0] b = _C[1] c = _C[2] This pattern is not just syntactic sugar, it is widely used in production code: Function return unpacking (return x, y) Iteration over structured data API responses and tuple-based records Why it matters: Removes manual indexing (less error prone) Improves intent readability Makes transformations explicit and compact One important constraint: If the structure does not match, Python fails fast with a ValueError, which is often a feature, not a bug. Clean syntax, strict alignment, predictable behavior. That is the philosophy behind Python’s design. Which Python feature felt too simple until you saw it in real systems? #Python #SoftwareEngineering #CleanCode #Programming #PythonTips #Coding #Developer #SystemDesign
To view or add a comment, sign in
-
🐍 Python isn’t simple. You just learned it wrong. A lot of developers say Python is easy. But what they really mean is: they never went deep enough. Here are 5 things that separate beginner Python from real Python: Everything is an object Even functions, classes, and modules. Understanding this changes how you design code. Mutability is not obvious Lists, dicts, sets → mutable Tuples, strings → immutable This impacts bugs more than people expect. Pass-by-object-reference (not value) Python doesn’t copy variables the way many think. This leads to side effects if you’re not careful. List comprehensions are more than syntax sugar They are faster, cleaner, and often more expressive — when used correctly. The standard library is underrated Modules like itertools, functools, and collections can replace a lot of custom code. Most developers stop at “it works”. Few go to “I understand why it works”. And that’s where the difference starts. What was the moment you realized Python was more complex than it looks?
To view or add a comment, sign in
-
More from this author
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
How to write scripts that reduce wait times using async Python: https://opsmill.com/blog/async-python-basics/