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.
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 & Tutorials
× 14The 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)
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.
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.
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.
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?
Based on PEP-101, this article combs through the CPython release process, draws a detailed flowchart, and provides explanations for key steps.
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.
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.
A detailed Django project tutorial that implements a full-stack project. The article includes a video tutorial by the author.
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.
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.
The article introduces some Python tricks, from beginner to advanced levels, mostly related to data structures, which are useful when solving LeetCode problems.
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
× 10A 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)
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)
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.
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)
The latest open-source face swapping library, with a rapidly growing number of stars! (6.9K stars)
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.
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.
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.
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.
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.