Skip to main content

Python

Multiprocessing, Multithreading and Asyncio in Python Part 1 - Basic Concept

·1131 words·6 mins
Python’s performance bottlenecks were criticized for years, but thanks to the hard work of developers, Asyncio was introduced in Python 3.4 to improve performance in specific scenarios. By Python 3.13, the Free-threaded design (PEP-703) emerged, allowing the optional disabling of the GIL. Combined with the pre-existing Multiprocessing and Multithreading, I have compiled a few records on the principles, differences, and use cases for these three technologies. This first post will briefly introduce the basic concepts and suitable scenarios for each.

Enterprise Standard: Asynchronous FastAPI Architecture

A production-grade, asynchronous Python microservice boilerplate engineered to standardize enterprise backend development and eradicate legacy I/O bottlenecks. Enforced strict organizational engineering culture by integrating Docker and mandating a baseline of 95% test coverage.

Pyenv Notes

·348 words·2 mins
Functions and Reasons for Using pyenv # pyenv is a tool used to install various versions of Python on a system, and to conveniently switch between Python versions. When you need to develop or maintain projects that require different Python versions simultaneously, you will need to use pyenv to help switch Python versions. New Python versions usually include syntax updates or new features.

Python Coroutine Asyncio

·845 words·4 mins
Before the advent of asyncio, when a Python program had many tasks that needed to be executed concurrently, and wanted to improve program performance, the only options were multiprocessing or threading. After Python 3.4, asyncio became another option. asyncio can be used to write coroutines, and execute coroutines concurrently using an event loop, reducing unnecessary waiting time in the program to improve performance.

Pipenv Notes

·400 words·2 mins
Why Pipenv # When maintaining many Python projects, different projects might use different versions of the same Python libraries. Not using a virtual environment and installing all Python modules directly on your machine will lead to version conflicts. In the past, the mechanism of virtualenv + requirements.txt allowed different projects to use different versions of the same package, and also enabled new developers or production environments to quickly install the packages required by the project.