The author emphasizes the importance of using Python's core features to write idiomatic, expressive, and elegant code, arguing that elegance is not an optional luxury.
TL;DR
The Pythonicity debate covers elegant code, immortal objects and other quirks; Khan Academy's rewrite of its Python backend in Go and pixi, a Rust-based Conda package manager, are meaty reads.
Articles & Tutorials
× 16This article introduces how to write a language-level tool for preventing cache penetration based on the characteristics of Asyncio.Future—Share, and introduces its usage and processing methods under high concurrency.
APScheduler is a robust library for handling scheduled tasks. This comprehensive article delves into the intricacies of the library, covering topics such as creating scheduled jobs, job triggers, job stores, concurrent execution, blocking and non-blocking schedulers, error handling, executing jobs immediately, scheduler persistence, job listeners, and removing scheduled jobs.
This article attempts to modify Python's lambda function into an arrow function in the style of Javascript. When compiling CPython, the abstract syntax tree is reconstructed by modifying the .asdl file, the syntax analysis file is modified, and the syntax analyzer is regenerated using pegen.
Are you curious about the underlying workings and internal structures of CPython? This article delves into the source code to explain how CPython implements reference counting and memory management. It covers the mechanics of reference counting, explains key data structures, explores the execution of bytecode instructions, and discusses the limitations of reference counting.
Lazy loading refers to importing modules when they are needed, rather than when the program starts. Its advantages include reduced startup time, lower memory consumption, improved performance, optimized resource utilization, and runtime loading. This article introduces the usage of importlib to achieve lazy loading.
End-to-end testing involves testing an application's entire user flow from start to finish, potentially uncovering issues that unit and integration tests may miss. This is a comprehensive introductory tutorial covering the usage of Playwright.
Although the Python official has announced that it will accept PEP-703, the final version may have to wait until version 3.17, five years later. Since 2021, the nogil and Faster CPython projects have continued to attract attention. This article reviews their development over the past two years, some key issues handling schemes and important progress, and recent responses from the community and large companies. (Attached: Python's first workshop on nogil, Faster CPython project debuts)
Instagram contributed PEP-683 (Immortal Objects with Fixed Reference Counting) to Python 3.12, which bypasses reference counting checks and is a key building block for multicore Python parallelism. The article tells the story of how Instagram encountered memory usage issues, introduced immortal objects to solve the problem, and eventually contributed it to CPython.
A file in Python is a module, which has its own namespace. When using "import *", it leads to "namespace pollution"! The article points out the correct way to follow the PEP-8 style, and also suggests that __all__ should be used to define the variable names that can be exported in the module.
pixi is a newly released Python package manager written in Rust. This article is from its official blog, mainly introducing why this project was developed, what features it provides, and its basic execution process. The project is currently based on the Conda ecosystem and does not support PyPI yet.
A very detailed tutorial that introduces what JWT is and how it works, and demonstrates the whole process of implementing JWT authentication with DRF.
Database queries are one of the major factors that affect the performance of web applications. This article introduces 7 tips to improve performance: set a timeout for query execution, use assertNumQueries to test the number of queries, use nplusone to catch N+1 queries, use django-zen-queries to catch N+1 queries, avoid making new queries on prefetched objects, use defer() to prevent fetching large unused fields, and avoid using distinct() on large fields.
Sometimes we see some strange phenomena in programming languages. They may be some very unpopular "features", or they may be mistaken for bugs or cause bugs due to misunderstanding. The author introduces several of his small discoveries.
Khan Academy used Python as its main language for 10 years, but around 2020, it completely switched to Go. This article introduces why and how it refactored the entire Python 2 backend to Go services. The article cites a series of summary blogs from Khan Academy, which can be used for further reading.
This is a long article about how programming languages should be designed! The author points out that modern programming languages have the problem of "static-dynamic polymorphism", and proposes that an ideal programming language should have both static and dynamic features. The article analyzes the practices of two languages, Idris and Zig, and points out their limitations. Finally, it proposes that programming languages should be rethought.
If you find the weekly valuable, please express your appreciation and support Python Cat~~
🎁 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
× 12A package manager based on the Conda ecosystem, supporting all operating systems, supporting Conda packages in multiple languages, having a Cargo-like command-line interface, and written entirely in Rust. It supports installing packages on a per-project basis, as well as installing them globally, similar to pipx and condax.
Supports packaging as Mac, Windows, Linux, Android and iPhone apps, as well as static web sites with PyScript as the client. (2K stars)
Last week's trending project, which can generate a digital avatar of an individual with only three photos. It utilizes the text-to-image capabilities of Stable Diffusion, and during training, users can select various LoRA models of different styles. It also supports adding personalized prompts to achieve cosplay effects. (3.2K stars)
Model-as-a-Service (MaaS) brings together the most advanced machine learning models from the AI community and simplifies the process of using AI models in real-world applications. It features 700+ models covering natural language processing, computer vision, speech, multimodal, and more. (3.6k stars)
Instead of searching for books based on conventional criteria like genre and title, Viberary allows users to search for relevant books using query prompts. It leverages the Two-Tower Semantic Retrieval Model, trains data locally using DuckDB, performs retrieval using the Redis Search module, and presents results through a Flask API and a Bootstrap frontend.
It provides a platform for open source maintainers to easily set up, run, and promote supporter-driven value-added and subscription services, helping developers earn revenue from their open source projects. The project has received $1.8 million in seed funding.
A really fun game! You play as an operating system, managing processes, memory, and I/O events. Don't let processes idle for too long, or it's game over! The project depends on Python 3.11 and pipenv, or you can play it online. (1k stars)
This project implements a relational database from scratch, inspired by the sqlite database. Key features: supports rich sql, uses lark to build a custom lexer and parser, supports user and proxy modes of connection, implements a BTree for data storage.
Faster and more feature-rich than other multiprocessing libraries: combines the advantages of shared objects with copy-on-write from multiprocessing.Pool , has extensive state management features, implements progress bars using tqdm, supports viewing progress in a dashboard, and more. (1.5k stars)
How do you compare the differences between two versions of a software? What matching techniques are involved when comparing binary software differences? This project claims to be the most powerful software diff tool out there! (3.1k stars)
A near real-time (NRT) pure-Python runtime type checker that brings Rust and C++'s zero-cost object types to the dynamically-typed world of Python. It selectively augments Python's duck typing with static typing while preserving the former's benefits by default. As the project documentation states, "You can quack like a duck and roar like a bear at the same time!" (2k stars)
This repository contains 200+ computer science books, for educational purposes only!
Podcasts & Videos
× 2This video from PyCon 2015 shows how to write elegant Python code. It has 8200+ likes on YouTube. The speaker, Raymond Hettinger, contributed to many well-known Python features, such as the enumerate() function, generator expressions, OrderedDict(), conditional expressions, and set objects.
Writing working code shouldn't be the end goal, it's just the beginning! This video uses magic methods like __getitem__, __len__, __enter__, and __exit__ to refactor hard-to-maintain code into something Pythonic. The author calls this an 8-minute summary of a previous talk.