Python Trending Weekly
ISSUE 20

Python Trending Weekly #20 (2023-09-16)

2023-09-16 Season 1

TL;DR

Why does Python run faster inside functions? That gem anchors the issue, alongside a switch from Poetry and PDM to Hatch and building Python extensions in Zig.

Articles 14 Projects 10
🦄

Articles & Tutorials

× 14
01 Three Ways to Benchmark Python Code superfastpython.com

This article introduces several methods for benchmarking Python using the standard library: time, timeit, cProfile, and profile. It provides detailed instructions on how to use these tools and how to interpret the test data.

02 Ditch Poetry and PDM, Switch to Hatch andrich.me

The author "fell in love" with Hatch and started using it in his projects. The article introduces some of the highlights he likes about Hatch: environment isolation, command scripts, an alternative to Tox, optional dependencies, and more. (See also: Python Task Automation Tool Tox Tutorial)

03 What's wrong with TOML? hitchdev.com

TOML is an "improved" INI file and is the recommended configuration file format for Python. The article mentions that even the author of TOML thinks it's a terrible format! The article points out its problems: it's very verbose, the hierarchy is hard to infer from the syntax alone, it's unnecessarily complex like YAML, and it has a type system.

04 Playing with Genetic Algorithms in Python joseprupi.github.io

Genetic Algorithm is an optimization algorithm inspired by the theory of biological evolution, used to solve complex search and optimization problems. The article demonstrates the usage of this algorithm with Python.

05 Type Hinting in Modern Python: The Protocol Class codebeez.nl

The Protocol class was introduced in Python 3.8 to specify which methods a class should implement, similar to an Interface in Java. Using a Protocol allows for some static type checking while still maintaining Python's dynamic typing.

06 Tornado's Coroutine Scheduling Principle dev.to

Tornado is a high-performance web framework. This article analyzes its source code, mainly to figure out: where does the state of yield go, what exactly is the "right time" to resume execution, and how exactly is execution resumed?

07 Visualizing the CPython Release Process sethmlarson.dev

Based on PEP-101, this article combs through the CPython release process, draws a detailed flowchart, and provides explanations for key steps.

CPython Build and Release Process
08 How to Use PyObjC with Apple's Vision Framework for Text Recognition yasoob.me

Apple's Vision framework provides a set of pretrained models and APIs to quickly add image analysis and computer vision capabilities to your apps. PyObjC enables Python to interact with Objective-C. This article combines them to develop a text processing project.

09 Regex Catastrophic Backtracking in Python krishnanchandra.com

The author used py-spy to locate a CPU 100% usage issue, found the culprit regular expression, and then explored catastrophic backtracking, its solutions, and suggested a better way to write it for performance.

10 Building a Database Search App with Django and HTMX photondesigner.com

A detailed Django project tutorial that implements a full-stack project. The article includes a video tutorial by the author.

11 Asynchronous SQLAlchemy and Multiple Databases python-bloggers.com

Utilizing asyncio and the SQLAlchemy library, the article explores how to efficiently connect to and manage multiple databases, achieving a scalable and resilient architecture. Two implementation approaches are presented.

12 Python Fire: Generate Command-Line Interfaces Automatically juejin.cn

Fire is a library for generating CLIs, open-sourced by Google with 25K stars on Github. This article introduces its usage, including general commands, composite commands, chained commands, complex commands, and more.

13 My Favorite Python Tricks for Solving LeetCode Problems jjinux.com

The article introduces some Python tricks, from beginner to advanced levels, mostly related to data structures, which are useful when solving LeetCode problems.

14 Why Does Python Code Run Faster in a Function? stackabuse.com

Python code is executed either in a function or in a global module. Which one is faster? Why is it faster in a function? How does Python code work under the hood? How to test and optimize the performance of Python functions?

🎁 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 hatch: A fancy extensible Python project manager github.com

A Python project manager with a standardized build system, powerful environment management, easy deployment to PyPI, version management, a responsive CLI, and is about 2-3x faster than similar tools like pipenv and poetry. (4.4k stars)

02 keep: Open-source alerting management and automation execution platform github.com

Integrate all alerts into a single management platform and orchestrate workflows to automate end-to-end processes. Supports docking with various data collection platforms, databases, office software, etc., and visualizes the orchestration of alert processing workflows. (star 2.2K)

03 PyPI Data Website: Explore PyPI's Data py-code.org

An amazing website! It contains various statistics, line charts, and pie charts about PyPI, such as the total number of files, the total size, and the popularity trends of some features.

Image of PyPI Data Statistics
04 strictyaml: A type-safe YAML parser and validator github.com

A restricted subset of YAML that parses and rejects ugly, unreadable, and insecure YAML features, with strict tag validation and a natural type system. An alternative to pyyaml, ruamel.yaml, and poyo, with clear and helpful error messages. (1.3k stars)

05 facefusion: A More Advanced Face Swapping Tool github.com

The latest open-source face swapping library, with a rapidly growing number of stars! (6.9K stars)

06 pyflyby: A Productivity Toolkit for Python github.com

A collection of small tools, including py for the command line, autoimport for IPython, adding missing imports, removing unused imports, formatting imports, printing the imports for a set of files, renaming imports, and more.

07 Instagraph: Convert text content or URLs into visual knowledge graphs github.com

Instagraph extracts entities from complex information and generates a graph of their relationships. It uses GPT-3.5 and Flask to generate colorful and user-friendly legends. It's also responsive, so it can be used on any device.

08 textual-web: Run TUIs and terminals in the browser github.com

Publish apps developed with Textual to the web, allowing them to be used as command-line terminals in the browser. This is a very interesting project.

09 ziggy-pydust: Build Python extensions in Zig github.com

A development framework to package Python extension modules written in Zig, including a Pytest plugin to discover and run Zig tests. Poetry integration makes it easy to build wheels and publish. Supports the buffer protocol, enabling zero-copy for faster Numpy computations.

10 MFTCoder: Multi-task Fine-tuning Code Large Model github.com

An open-source multi-task code-large-language-model project, including model, data, and training for code-large-language-models. Achieved 74.4% open-source SOTA on HumanEval Benchmarks Python Pass@1, surpassing GPT-4.

ESC
↑↓ select · ↵ open175 issues