The Faster CPython project (aka Project Shannon) has a new plan for the 3.13 release, with a performance goal of reducing the interpreter's time by 50%. It covers three major efforts: a tier 2 optimizer, enabling subinterpreters (PEP-554), and memory management.
TL;DR
Python 3.13 targets a 50% interpreter speedup, while the community shows how under 100 lines of Rust can make Python 100x faster; NumPy's parallelism gets its due too.
Articles & Tutorials
× 12NumPy is one of the most important libraries for scientific computing and data analysis, and parallelism is a key technique to improve its performance. This article introduces five scenarios and methods to achieve NumPy parallelism: loading/saving NumPy array data, efficiently computing mathematical functions, efficiently initializing arrays, performing element-wise mathematical operations on arrays in parallel, and efficiently sharing NumPy array data across processes.
The article describes how a Python library with performance issues was rewritten in Rust and optimized in three rounds, resulting in a 100x performance improvement. The py-spy library was used to generate flame graphs, which helped identify the bottlenecks in the code and served as the basis for optimization. The difference between the flame graphs before and after optimization is significant.
The article points out some problems with the "port-in-one-go" approach, and proposes an "iterative porting" approach, and gives a code example.
How do you design a Pythonic API? What are some of the design approaches and principles? The article provides a very detailed introduction in terms of code structure, variable naming, error handling, version control, type annotations, and more. The article is long and concludes with 18 takeaways.
Python now supports type hints, so is it possible to compile Python code to native code for better performance? While type hints can provide some performance improvements, the dynamic and flexible nature of Python makes static analysis and compilation very difficult. As a result, there is currently no way to compile Python code to native code for performance gains.
Fixtures are a mechanism for setting up and tearing down resources before and after tests, separating test data and test code. This article introduces the basic usage of fixtures in pytest, and how to use them with Django projects.
This is a series of articles that help you explore the implementation of Python dictionaries with visual debugging. This article introduces how to implement a dictionary with a hash table and how to resolve hash collisions.
This article provides an in-depth comparison of Flask and Django, two of the most popular Python web frameworks. It covers their key features, advantages and disadvantages, popular plugins, and use cases, helping readers make an informed choice.
The article aims to introduce a basic Python packaging workflow that minimizes dependencies and requirements and solves packaging problems for most users. It lists common packaging problems and provides solutions, while also pointing out the drawbacks of popular packaging tools like homebrew, pyenv, anaconda, and poetry.
This article explores writing concurrent code in PyScript/Pyodide using async/await/asyncio. It also introduces the implementation of Pyodide.Webloop, which enables async/await to work with the browser event loop.
In contrast to the three articles in the first segment of last week's issue that favor implicit async, a reader suggested presenting viewpoints that support explicit async. This article argues that threads make local reasoning difficult, which is one of the most important things in software development. Therefore, instead of using threads, one should use asynchronous programming models such as callbacks, promises, and coroutines. It also mentions the risks of using implicit coroutines, as they can lead to the same problems as threads. (Submitted by @Plutonium)
🎁 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
× 8There are few open-source and aesthetically pleasing PyQt/PySide widget libraries, so the author wrote this Fluent Design style widget library based on the WinUI3 design draft. It supports seamless switching between light and dark themes and custom theme colors, and is compatible with PyQt5/PyQt6/PySide2/PySide6. It can be used with QtDesigner to quickly design beautiful interfaces. (From @shokokawaii)
PyVibe is a Python library for creating web pages, allowing Python developers to quickly build front-end pages and simplify UI development. PyVibe returns an HTML string that can be used for static pages, Flask functions, and Pyodide dynamic client-side rendering.
Pynecone was released in December 2022 and has gained 9K stars, making it quite popular. It is a full-stack framework for building and deploying web applications. It provides 50+ built-in components, supports creating complex layouts, and allows you to style them using the full power of CSS.
This repository contains a collection of small and challenging coding problems, including Advent of Code puzzles, The Riddler puzzles, word puzzles, probability puzzles, and more. It even has a Sudoku solver in Python and a Lisp interpreter, among other things.
Recognize Anything Model is an image tagging model that can recognize any common categories with high accuracy; Tag2Text is a tag-guided visual language model that can support captioning, retrieval, and tagging. This project is the code implementation of these two models.
Allows to talk to multiple PDF files at the same time using natural language. The project uses streamlit to display the user interface in a web browser.
DeepKE is a knowledge extraction toolkit for knowledge graph construction, supporting entity, relation, and attribute extraction in cnSchema, low-resource, document-level, and multimodal scenarios. Three main functions: named entity recognition, relation extraction, and attribute extraction. The project provides detailed documentation, tutorials, and online demos.
A collection of awesome lists about all things DevOps, including platforms, automation, CI/CD, code management, web servers, databases, monitoring tools, gateways, chaos engineering, and more.
Discussion & Questions
× 2A hot discussion about the development plan for Python 3.13. As expected, most of the comments are about GIL, both for and against.
This was also an HN thread that sparked discussions about programming languages themselves as well as some great projects in different programming language ecosystems. Interestingly, three comments about Python all recommended the pytudes project that we shared earlier!