DEV Community

豌豆花下猫
豌豆花下猫

Posted on

Python Trending Weekly #39 (2024-02-24)

Welcome to the Python Trending Weekly, a weekly newsletter about Python, AI and general programming techniques, with the majority links in English and a small portion in Chinese.

The original version of the weekly was written in Chinese. What you are reading here is mostly translated by LLMs.

Substack Channel : Click to subscribe

🦄Articles & Tutorials

  1. uv: Python packaging in Rust

Ruff team developed a powerful tool in Rust: uv, a package resolver and installer for Python! It's designed as a drop-in replacement for pip and pip-tools, and it's 8-10x faster than them when not using a cache. It can also be used as a virtual environment manager via uv venv, which is 80x faster than python -m venv and 7x faster than virtualenv.

Performance comparison for resolving and installing the Trio library

  1. Rye: A Vision Continued

Rye is a Python packaging and project management tool released by the author of Flask in April last year. In the article, the author summarized its implemented functions (downloading Python, managing virtual environments, building and releasing packages, linting and formatting, dependency management, etc.), and introduced his design ideas. (Appendix 1: The author's 16-minute tutorial video Rye: a Hassle-Free Python Experience) (Appendix 2: The uv team that shared last time has taken over Rye, and it will be integrated into one in the future. Rye Grows With UV)

  1. The Python Rust-aissance

Rust is progressively replacing C as the high-performance backend for Python. The article introduces the advantages of Rust over C and presents some well-known Python libraries developed with Rust.

  1. A search engine in 80 lines of Python

This article is a bit clickbaity, but the content it introduces is very comprehensive: asynchronous crawlers based on RSS, inverted indexes, search rankings, and web pages based on FastAPI. You can learn how search engines work and learn the project development process from data acquisition, data parsing, open interfaces, to web page presentation.

  1. Counting CPU Instructions in Python

Do you know how many CPU instructions it takes to execute print("Hello") in Python? The answer is 17,000. Importing seaborn takes about 2 billion. The author developed the Cirron library to count CPU instructions, branch misses, and time spent in code.

  1. Python Reusable Decorator Code

You have multiple decorators to add to different functions, and the same decorator may have different parameters. How do you reuse these decorators? The problem may be difficult to understand at first glance, but the article contains intuitive examples and solutions that can deepen your understanding of decorators and help you master advanced applications.

  1. Handling Tasks in Asyncio Like a Pro

What is a Task object in Asyncio? How do Asyncio coroutines work? How do you await a task, and how do you await multiple or a group of tasks? This article explains how Asyncio works and the functions you can use to work with tasks.

  1. Everything You Can Do with Python's textwrap Module

This article introduces several major functions of the textwrap library, such as shorten() for truncating string length, wrap() for wrapping a string to a fixed width, and dedent() for handling string indentation.

  1. Summary of Major Changes Between Python Versions

When were some of Python's new features introduced? The author has conveniently compiled a record of some important changes to the syntax and standard library, as well as indicating when each version will reach its end of life (for example, Python 3.8 will reach EOL in October of this year). (Note: This website provides EOL dates for Python and many other projects.)

  1. Postgres as a Queue

If you use a database directly as a queue, will performance be significantly affected? The author's tests show that the impact is minimal. How exactly can you implement Postgres as a queue? How do you handle locks and transactions, task retries, and task timeouts?

  1. 20 Django Packages That I Use in Every Project

The Django framework is suitable for building complex web projects, and the author introduces 20 commonly used packages that provide richer functionality beyond Django's core features.

  1. Real Case of Python Metaclass Application

What is a metaclass in Python? Why should you learn about metaclasses? This advanced feature is not commonly used, but it's worth learning and understanding. The article explains how metaclasses work and demonstrates their powerful uses with real-world examples.

  1. One Trillion Row Challenge

A programming challenge: given 100,000 files, each with 10 million rows, calculate the minimum, average, and maximum temperatures for each weather station. The data is stored on S3 and has a total size of 2.5 TB. The author provides their own implementation (which runs in 8.5 minutes), as well as a cost-optimized solution.

🎁 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

  1. uv: An extremely fast Python package installer and resolver, written in Rust

uv is an extremely fast Python package installer and resolver written in Rust. It is a product of the Ruff team and can directly replace commonly used commands such as pip, pip-tools, and virtualenv. (6.6K stars)

  1. sqlite-web: Web-based SQLite database browser written in Python

A web-based SQLite database browser built with Flask, which allows you to visually manage your databases, tables, records, and indexes, and import and export data in JSON and CSV formats. (2.6k stars)

  1. celery-exporter: A Prometheus exporter for Celery metrics

Real-time monitoring metrics for Celery task state, worker threads, active tasks, etc. It follows Prometheus exporter best practices and provides Grafana dashboards and Prometheus alerts using Celery-mixin.

  1. pyupgrade: A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language

A powerful tool and pre-commit hook to automatically remove redundant constructs, rewrite legacy code with modern syntax, refactor code to a more idiomatic style, and more. The project documentation provides many examples, which are worth checking out. (3.2k stars)

# Two examples rewritten as dict comprehensions
-dict((a, b) for a, b in y)
+{a: b for a, b in y}
-dict([(a, b) for a, b in y])
+{a: b for a, b in y}
Enter fullscreen mode Exit fullscreen mode
  1. ollama-python: Ollama Python library

Supports Python 3.8+, easy and fast integration with large language models such as Llama 2, Code Llama, mistral, gemma, etc. It allows for custom clients and also enables the creation of asynchronous clients.

  1. web2pdf: CLI to convert Webpages to PDFs

A command-line tool to convert webpages to beautifully formatted PDFs. It supports batch conversion, custom styling, appending CSS, complex layouts, page numbers, table of contents, and pagination, among other features.

  1. natural-sql: A series of top performing Text to SQL LLMs

NaturalSQL-7B is a highly accurate text-to-SQL large language model that outperforms GPT-3.5-turbo and claude-2 on the SQL-Eval benchmark, as well as sqlcoder-7b with the same data size.

  1. rawdog: Generate and auto-execute Python scripts in the cli

Rawdog (Recursive Augmentation with Deterministic Output Generation) is a novel alternative to RAG (Retrieval Augmented Generation) that can run scripts itself and take the output as context, then call itself again. The example in the demo video is mind-blowing. (star 1.6K)

  1. UFO: A UI-Focused Agent for Windows OS Interaction

Microsoft's new AI agent framework seamlessly operates across multiple applications to complete complex user tasks. It leverages GPT-Vision's multimodal capabilities to understand application UIs and interacts using Windows UI Automation controls. (1.9k stars)

  1. toolong: A terminal application to view, tail, merge, and search log files (plus JSONL)

Quickly view log files in a command-line terminal with features like live tailing, syntax highlighting, fast searching, automatic timestamp detection for merging logs, JSONL support, and automatic opening of .bz and .bz2 files. (2k stars)

  1. A personal wearable AI that runs locally

Bring AI to your wearable device to listen and observe your life. It supports hardware like ESP platforms, Sony Spresense, or Apple Watch, local and online models, multimodal capture, speaker verification, and more.

  1. hyperdiv: Build reactive web UIs in Python

A framework for rapidly developing reactive UI applications in Python, featuring built-in components, a concise declarative syntax, and minimal tooling boilerplate. It supports Shoelace components, Markdown support, Chart.js integration, browser cache read/write, form validation, and more.

  1. fabric: an open-source framework for augmenting humans using AI

This project aims to make AI accessible to everyone for solving everyday problems. Its approach is to break down problems into independent components and use structured, clear prompts to have AI complete tasks. (5.6k stars)

🐢Podcasts & Videos

  1. Meta loves Python

A podcast episode from Meta, discussing the contributions of their developer teams to recent versions of Python, including new hooks that allow for custom JITs (like Cinder), immortal objects, improvements to the type system, faster comprehensions, and more. Meta really is a big contributor to the Python community! (See also: Google, Microsoft, Meta? Who's the biggest sponsor of Python?)

  1. Episode #449 Building UIs in Python with FastUI

FastUI is a web frontend framework that lets you build responsive web applications using React without writing any JavaScript or dealing with npm. The creator of the framework joins the show to talk about it.

🐼Subscribe Welcome

  • Blog: Explore my independent blog where you can find a collection of original/translated technical articles over the years, along with some reflections since 2009.
  • Newsletter: Subscribe to my channel on Substack for a curated newsletter delivered straight to your inbox, keeping you updated on current affairs.
  • Github: Access the Markdown source files of this weekly digest on Github and feel free to use them for anything you have in mind!
  • Telegram: Beyond notifications for the weekly digest, I consider it an "extra edition," providing additional, more diverse information.
  • Twitter: Follow me on Twitter where my feed is filled with numerous accounts of developers and organizations in the Python community.

Top comments (0)