<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python - Category - Techstay's Tech Blog</title><link>https://techstay.tech/categories/python/</link><description>My tech blog, focused on technology</description><generator>Hugo 0.166.0 &amp; FixIt v1.0.0-alpha.2</generator><language>en-US</language><lastBuildDate>Fri, 11 Sep 2026 03:32:39 +0800</lastBuildDate><atom:link href="https://techstay.tech/categories/python/index.xml" rel="self" type="application/rss+xml"/><item><title>Understanding Python Asynchronous Programming in 10 Minutes</title><link>https://techstay.tech/posts/understanding-python-async-in-ten-minutes/</link><pubDate>Fri, 09 May 2025 00:00:00 +0000</pubDate><guid>https://techstay.tech/posts/understanding-python-async-in-ten-minutes/</guid><category domain="https://techstay.tech/categories/python/">Python</category><description>&lt;p&gt;Today, I&amp;rsquo;ll introduce how to use asynchronous programming in Python. This article focuses on the usage of asynchronous programming, so it won&amp;rsquo;t delve too much into underlying concepts.&lt;/p&gt;&#10;&lt;h2 class="heading-element" id="brief-introduction-to-concepts"&gt;&lt;span&gt;Brief Introduction to Concepts&lt;/span&gt;&#10; &lt;a href="#brief-introduction-to-concepts" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Coroutine&lt;/strong&gt;: A special function marked with &lt;code&gt;async&lt;/code&gt; that can execute code asynchronously.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Event Loop&lt;/strong&gt;: The core of Python asynchronous programming, responsible for scheduling coroutines.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Future&lt;/strong&gt;: A low-level object representing the eventual result of an asynchronous operation.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Task&lt;/strong&gt;: A wrapper for Future that can encapsulate coroutines and supports operations like cancellation.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;We all know that in operating systems, creating and switching processes and threads is very resource-intensive, making it prone to performance bottlenecks under high loads. Coroutines, on the other hand, are smaller execution units defined within the program. Since they don&amp;rsquo;t involve the overhead of process and thread context switching, coroutines are much lighter. We can easily create and run thousands of coroutines in a program—something that would be impossible with processes and threads.&lt;/p&gt;</description></item></channel></rss>