A newly released Python compiler (currently in alpha) that aims to provide high-performance Python. It compiles Python code with type hints to optimized machine code, supports both ahead-of-time (AOT) and just-in-time (JIT) compilation, allows interoperability with CPython, and supports multiple backends such as LLVM, C, C++, WASM, Julia, and x86.
TL;DR
LPython, a high-performance Python compiler, debuts alongside PythonMonkey, which embeds a JavaScript engine in the Python VM; memory profiler memray and Cython 3.0.0 round out the issue.
Articles & Tutorials
× 15Cython is a programming language designed to make writing C extensions for Python as easy as possible. It has recently jumped from version 0.29.x directly to 3.0.0, bringing a wealth of bug fixes and new features. This changelog is extensive. (Also, here is a detailed explanation of the changes in Cython 3.0 over the past five years, summarizing several major changes in this version.)
The coefficient of variation (CoV) is a statistical measure that assesses the relative variability or dispersion of a dataset in relation to its mean. The article introduces the formula, interpretation, significance, and practical applications of the coefficient of variation, as well as how to calculate it using Pandas and NumPy.
Jupyter Notebook now supports AI capabilities, which are currently available for free. This tutorial from the official blog guides users on how to use Jupyter AI to complete various tasks in a chat interface. It supports large language models from AI21, Anthropic, AWS, Cohere, HuggingFace Hub, and OpenAI.
Have you used Python 3.10's pattern matching syntax? This article explores the elements of this syntax (basic structure, demonstration of each pattern), and ponders whether the pattern matching syntax is really necessary to replace elif.
Rich is a library for rich text and pretty styles in the terminal (featured in this issue's "Projects & Resources"), and this post introduces its inspect() function, which lets you explore a Python object's attributes and available API.
An obscure topic discussing Python package version numbers. I never knew there were 6 components to a Python package version! The bulk of the article is an introduction to and explanation of PEP-440 (Version Identification and Dependency Specification), with a final section on version naming rules for Wheel packages.
What are the techniques to improve the performance of file I/O operations using concurrent programming? The article introduces four patterns (single-threaded, thread pool/process pool, batching tasks, thread pool in process pool) and discusses how to choose a more suitable pattern.
Reading code is an essential skill for all programmers. But how can we read and understand someone else's code efficiently? This article introduces some reading strategies and techniques, which can also help us write more readable and understandable code from the reader's perspective.
Java and Python have their own advantages. How can we combine them? This article introduces how to call Java using JPype and Pyjnius, and points out the challenges and limitations of the implementation.
The article introduces the usage of the PythonMonkey library, which enables loading and running JavaScript code in Python, as well as using WASM in Python. (With other articles by the author: Executing Rust in Python Using WebAssembly, Calling C Function from Python Using WebAssembly
There are several contents related to Textual in this issue of the weekly! Compared with the graphical user interface (GUI), the text user interface (TUI) is more responsive, has lower system requirements, and is easier to automate. This article builds a ChatGPT dialog tool using Textual.
How to use the currently popular vector databases in Python? This article introduces indexing and searching vector data using more than 10 databases, including ClickHouse, OpenSearch, pgVector, Pinecone, Redis, and so on.
CPython is the official interpreter implementation of Python. This long article introduces its compilation process, including syntax parsing, abstract syntax tree, bytecode, pyc parsing, and other contents.
The author points out the shortcomings of Python's built-in pdb and other debuggers (such as ipdb, pdbpp), introduces the fixes and improvements made by pdbp he developed, and provides a simple introduction. This library has few dependencies and is powerful. It is worth a try.
🎁 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
× 12This website is amazing, and I highly recommend checking it out! The homepage features a learning roadmap that illustrates various learning paths and content categories. It also includes several programming project challenges. Clicking on each node takes you to the corresponding content page. (It would be interesting to develop a similar website for Chinese readers.)
You may already know Python Tutor, an educational tool that provides an online interactive Python programming environment. The Pandas Tutor introduced here is a similar website that allows you to write Pandas code in a browser and visualize how the data is being transformed. (An article by two authors introduces their work of porting Pandas Tutor to Pyodide to facilitate teaching data science at scale.)
This is a tutorial hosted on Read The Docs that introduces how to use SQL and Jupyter for data analysis, covering chapters on working with databases, advanced querying techniques, data visualization (seaborn, plotly, ggplot), project packaging, deployment, and monitoring. It is part of the open-source project ploomber (3.1K stars), which is a project for building data pipelines fast.
This is a sister project of pystack, which was introduced in issue #12 of the weekly. It can track memory allocations in Python code, C/C++ extension modules, and the Python interpreter itself. It supports native mode and live-view mode, and can generate multiple types of reports. It provides a Pytest plugin pytest-memray that allows you to view memory reports after running a test suite. (11k stars)
MS Paint is a simple image editing software developed by Microsoft. This project is a TUI image editor in the style of MS Paint, supporting opening and saving images in the terminal, all the tools in MS Paint, a color palette, brush preview, and more.
Rich is a Python library that allows you to create beautiful and informative text in your terminal. It can be used to create tables, progress bars, Markdown, syntax highlighting, and stack traces. (44.2K stars) The image below shows some of its features:
This is a JSON parsing library developed in Rust that addresses the pain point of large files not being able to be loaded into memory. It solves the memory consumption problem by converting JSON to JSONL format. Tests show that when processing a 500MB file, the Python standard library uses 2GB of memory, while this library only needs 1.5MB, and the speed difference is very small.
PythonMonkey, which has been mentioned before, embeds Mozilla's SpiderMonkey JavaScript engine into the Python virtual machine, using the Python engine to provide a JS host environment. The goals of this project include calling JavaScript libraries in Python and calling Python libraries in JavaScript. If the ecosystems of these two languages can be effectively connected, the future is immeasurable!
cuDF is a GPU DataFrame library for loading, joining, aggregating, filtering, and otherwise manipulating data, built on the Apache Arrow columnar in-memory format. It provides a pandas-like API, without the need to know the details of CUDA programming. (5.8K stars)
A smaller version of Stable Diffusion made through "knowledge distillation", which can generate images with comparable quality to SD while being much faster and having a smaller footprint.
A framework for high-performance tracking and segmentation of objects in videos, consisting of a Video Multi-Object Segmentor (VMOS) and a Mask Refiner (MR), which can track multiple objects simultaneously and output accurate object masks.
An awesome list of curated MLOps tools, including a wide variety of projects/tools, as well as resources such as articles, books, events, podcasts, and websites.
Podcasts & Videos
× 1This episode of the "Projects & Resources" segment features Memray, and the podcast invites two guests to talk about the project in depth.