In CPU-intensive tasks, the size of the thread/process pool is usually set according to the number of CPU cores. But how do you determine how many CPUs are actually best to use? What are physical and logical CPUs? How do you test how many CPUs are appropriate to set?
TL;DR
Building feedi, a personal news aggregator, takes center stage; CPython stripping out private C API functions and how many CPUs parallel Python can really use round it out.
Articles & Tutorials
× 10Python beginners often encounter package-related issues, one of the main reasons being that they are not clear about how Python finds packages. This article introduces the order in which Python searches for packages, how it installs packages, the role of virtual environments, and how the way a script is run affects the search path.
Victor Stinner, a prolific core developer, removed over 300 private C API functions in Python 3.13 alpha 1, received some negative feedback, and restored 50 of them in alpha 2. The post documents what he did and the feedback he got from the community.
How do you create a copy of a mutable object like a list? For one-dimensional lists, the article introduces three methods; however, for two-dimensional lists, the issue of shallow copy versus deep copy arises, and copy.deepcopy() must be used. (Note: The author's "Python Gotcha " series of short articles introduces some usage considerations for Python.)
Asyncio tasks can be canceled manually or automatically. This article introduces six best practices and provides corresponding examples.
How can we store mutable or sensitive parameters in a configuration file? We can use files like ini, json, toml, yaml, or environment variables. When should we initialize the configuration? How can we modify the configuration during tests? This article shares some usage tips.
This article introduces some best practices for configuring your web server (involving Gunicorn, Uvicorn, and Hypercorn). It covers the differences between the ASGI and WSGI standards, how to set the number of workers and threads, how to use tools like Locust for testing, and which approach to use for different web frameworks.
Python does not support the ternary operator, but it has a very special conditional selection syntax. Why is it designed this way? The article sorts out the tortuous syntax design story of Python, and at the same time introduces the coincidental practices of Go and Rust, which makes people think about what is better syntax design in programming languages?
You may have seen the key parameter in the sorted() and list.sort() functions, but it is also available in many other functions, such as max() and min(). This article explains how to use the key parameter in these functions.
In Python, you can use the @dataclass decorator to define data classes, which automatically add magic methods like __init__, __repr__, and __eq__, reducing the amount of code you need to write. The author recommends defining immutable data classes and avoiding mutating their attributes like you would with a regular class. If you need to use methods like __repr__ in a regular class, it is better to implement them manually.
🎁 Python Trending Weekly 🎁 organizes its content into seasons, with every 30 issues forming a season. The highlights from the first season have been compiled for your convenience. You can access them online here (Chinese).
Projects & Resources
× 10Do you want to have a personalized content reader? It supports parsing RSS feeds, fetching Mastodon messages, reading bookmarks, local article reading and previewing, and sending to Kindle. (Appendix: Why and how the author developed this project Reclaiming the Web with a Personal Reader)
Google's generative AI development toolkit to quickly build AI applications on top of the Gemini and PaLM large models. Supports text generation, multi-turn dialogue, embeddings, and more.
It can automatically detect and exploit SQL injection flaws and take over database servers. It features a powerful detection engine, database fingerprinting, data retrieval from the database, accessing the underlying file system and executing commands on the operating system. (star 29.4K)
A data collection tool based on the Requests module with comprehensive functions! Supports command line mode, Web UI mode, and interface invocation mode. (1.5K stars) (Note: In the 25th issue, the author's Xiaohongshu collection tool XHS_Downloader was shared)
This is a project that amazed me with its demo effect! Just look at the demo image below:
Quickly build your personal blog and podcast website with Django, using Wagtail as a CMS to easily manage your posts and podcast episodes. Supports podcast and video playback, comments and spam filtering, and customizable site themes.
Hexo blog backend management, custom image upload, online page management, open API, one-click update, quick access to friendly links. (star 1.2K)
A resource-rich project with a huge number of stars, divided into different programming languages and technical fields, collecting many tutorials on practical projects. (142K stars)
Its goal is to provide a platform to study converting arbitrary inputs to audio. It supports TTS text-to-speech, SVC singing voice conversion, TTA text-to-audio, and widely used neural vocoders. (2.2K stars)
Podcasts & Videos
× 3Some videos from this year's PyConChina event have been released and are available to watch on Bilibili.
PyCoder's Weekly is a weekly podcast that I've been following for a long time. This episode is a year-in-review episode where they discuss topics such as the top 5 clicked links, some of the biggest news stories of the year, major themes and trends of the year, and cool projects, among other things.
This video compares using requests, httpx, and aiohttp, discussing topics such as using asynchronous requests.