Python Trending Weekly
ISSUE 16

Python Trending Weekly #16 (2023-08-19)

2023-08-19 Season 1

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 16 Projects 12 Media 2
🦄

Articles & Tutorials

× 16
01 Does Elegance Matter When Writing Code? mathspp.com

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.

02 Python Asyncio in Practice: How to Prevent Cache Penetration Under High Concurrency so1n.me

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

03 Efficiently Handling Scheduled Tasks: Delving into the Nuances of the APScheduler Library in Python juejin.cn

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.

04 CPython Development Practice: Modifying the lambda Function juejin.cn

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.

05 How Does CPython Implement Reference Counting? codeconfessions.substack.com

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.

06 Python Lazy Loading with Importlib coderslegacy.com

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.

07 End-to-End Testing with Python and Playwright sixfeetup.com

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.

08 The nogil and Faster CPython projects lwn.net

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)

09 Immortal Objects for Python: A Deep Dive engineering.fb.com

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.

Increasing shared memory, reducing private memory and copy-on-write
10 Why You Should Avoid Using "import *" in Python pybit.es

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.

11 Let's End Python's Dependency Hell prefix.dev

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.

12 JWT Authentication using Django Rest Framework pythonguides.com

A very detailed tutorial that introduces what JWT is and how it works, and demonstrates the whole process of implementing JWT authentication with DRF.

13 Speed Up Your Django App: 7 Tips for Faster Database Queries johnnymetz.com

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.

14 Weird Python "Features" That Might Surprise You martinheinz.dev

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.

15 How Khan Academy Rewrote Their Python Backend in Go blog.quastor.org

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.

16 Why Static Languages Suffer from Complexity hirrolot.github.io

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

Why Static Languages Suffer from Complexity
🐿️

Projects & Resources

× 12
01 pixi: A Conda-based package manager written in Rust github.com

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

Demonstration of pixi usage
02 briefcase: Convert Python projects into standalone apps github.com

Supports packaging as Mac, Windows, Linux, Android and iPhone apps, as well as static web sites with PyScript as the client. (2K stars)

03 facechain: A deep learning toolkit for generating digital avatars github.com

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)

04 ModelScope: Making the Model-as-a-Service Concept a Reality github.com

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)

05 Viberary: A Semantic Book Search Engine github.com

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.

Book search processing flow
06 Polar: Helping open source maintainers get better funding github.com

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.

07 youre-the-os: A game where you play as an operating system! github.com

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)

Screenshot of gameplay
08 learndb-py: LearnDB by implementing a database from scratch github.com

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.

09 mpire: A multiprocessing library faster than the standard library github.com

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)

10 diaphora: A diff tool for binary files github.com

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)

Screenshot of iOS 9.3.5 fixing a kernel vulnerability
11 beartype: A near real-time static type checker github.com

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)

12 cs_books: Computer science books recommended by AzatAI github.com

This repository contains 200+ computer science books, for educational purposes only!

🐢

Podcasts & Videos

× 2
01 Beyond PEP-8 -- Best Practices for Beautiful, Understandable Code youtube.com

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

02 5 Steps to Turn "Barely Working" Code into Pythonic youtube.com

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.

ESC
↑↓ select · ↵ open175 issues