Python Trending Weekly
ISSUE 32

Python Trending Weekly #32 (2023-12-23)

2023-12-23 Season 2

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 10 Projects 10 Media 3
🦄

Articles & Tutorials

× 10
01 How many CPUs can actually be used in parallel programs? pythonspeed.com

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?

02 Where Do Your Python Packages Go? frostming.com

Python 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.

03 Removing C API functions from CPython vstinner.github.io

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.

04 Python Gotcha: The Problem with Copying Lists andrewwegner.com

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.)

05 Best Practices for asyncio Task Cancellation superfastpython.com

Asyncio tasks can be canceled manually or automatically. This article introduces six best practices and provides corresponding examples.

06 Configuration in Python applications: no magic, just necessary practice robertrode.com

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.

07 Fine-tuning Flask, Django, and FastAPI applications in Python tonybaloney.github.io

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.

08 Why Do Python, Go, and Rust Not Support the Ternary Operator? pythoncat.top

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?

09 The Key to the `key` Parameter in Python thepythoncodingstack.com

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.

10 Eliminating Mutating Methods from Python Data Classes rednafi.com

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

× 10
01 Feedi: Build Your Own Personalized News Aggregator github.com

Do 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)

Image of Feedi's interface
02 generative-ai-python: Develop Gemini and PaLM applications with Google AI SDK github.com

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.

03 python-guide-for-javascript-engineers: Open-source e-book "Python Guide for JavaScript Engineers" github.com

An open-source e-book based on abook that covers everything from Python environment installation to project development. It helps JavaScript engineers quickly master the Python language by comparing and contrasting JavaScript and Python in numerous examples. (Contributed by @luckrnx09)

04 sqlmap: SQL injection and penetration testing tool github.com

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)

05 TikTokDownloader: TikTok and Douyin Data Collection Tool github.com

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)

06 Osprey: Fine-tuning Pixel Understanding through Visual Guidance github.com

This is a project that amazed me with its demo effect! Just look at the demo image below:

Visual understanding of the content in Along the River During the Qingming Festival
07 django-cast: A blog/podcast project based on Django and Wagtail github.com

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.

08 Qexo: Fast, Powerful and Beautiful Hexo Editor github.com

Hexo blog backend management, custom image upload, online page management, open API, one-click update, quick access to friendly links. (star 1.2K)

09 project-based-learning: A curated list of project-based tutorials github.com

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)

10 Amphion: A toolbox for audio, music, and speech generation github.com

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

× 3
01 PyConChina 2023 Speech Videos space.bilibili.com

Some videos from this year's PyConChina event have been released and are available to watch on Bilibili.

List of videos from PyConChina 2023
02 Episode #184: PyCoder's Weekly's 2023 Year in Review realpython.com

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.

03 Requests vs Httpx vs Aiohttp: Which One Should You Choose? youtube.com

This video compares using requests, httpx, and aiohttp, discussing topics such as using asynchronous requests.

ESC
↑↓ select · ↵ open175 issues