Using the example of counting letter frequencies in English novels, this article demonstrates four different code optimization approaches: achieving 2x improvement by reducing redundant calculations, 10x speedup using Rust implementation, further performance gains through parallel multi-core processing, and process optimization to ensure measurement accuracy, ultimately achieving a 330x performance boost.
TL;DR
Four optimizations produce a 330x spread on the same problem; Anthropic explains how it built its multi-agent research system, and the tail-call interpreter pushes Python 3.14's performance further.
Articles & Tutorials
× 13Creating function local aliases in Python is a traditional trick for optimizing loop performance. This article analyzes bytecode and virtual machine implementation mechanisms to reveal how CPython 3.11's instruction specialization optimization makes this manual optimization unnecessary.
Python 3.14 introduces the Tail Call Interpreter mechanism, which splits massive switch-case structures into multiple small functions and leverages tail call optimization to solve compatibility issues with traditional Computed Goto across different compiler versions, improving overall performance predictability.
The author discovered 6 uncommon but practical programming techniques in the source code of well-known Python libraries: using super() in base classes for cooperative multiple inheritance, implementing optional features with Mixins, using relative imports to avoid naming conflicts, simplifying API interfaces in init.py, and leveraging empty conftest.py files to automatically configure pytest paths.
A deep dive into the source code implementation of Python's standard library shelve module, demonstrating how to create persistent dictionary objects. Internally, it serializes arbitrary Python objects through pickle and delegates storage to the dbm module. The article provides detailed analysis of caching mechanisms, context manager design, and other elegant programming techniques.
Anthropic developed a multi-agent research system where a lead agent coordinates multiple sub-agents to search information in parallel, achieving a 90.2% performance improvement over single-agent systems. The article shares valuable insights on system architecture design, prompt engineering techniques, and production environment reliability challenges.
The author explores LLM's impact on Domain-Specific Language (DSL) design, noting that while LLMs excel with mainstream languages like Python, their performance drops dramatically with niche languages, effectively doubling the opportunity cost of DSLs. The article proposes three response strategies: teaching LLMs to understand DSLs through Python as an intermediate language, designing new DSLs that can collaborate with LLMs, and developing specification languages for validating LLM-generated code.
An in-depth analysis of Python global variables' bytecode implementation mechanism, revealing how the virtual machine handles global variables through dynamic name resolution while local variables use index access. The article analyzes global storage principles through the LOAD_GLOBAL instruction, explaining how this design enables Python's dynamic features, including runtime global variable modification and cross-module monkey patching.
A comprehensive introduction to Python regular expressions usage and principles, covering basic metacharacters, escape characters, extensive examples (such as greedy matching, non-greedy matching, zero-width assertions), and advanced regex features (such as capture groups, non-capture groups, named groups) and other advanced characteristics.
Pyodide solves the compatibility issue between synchronous Python code and asynchronous JavaScript APIs in browsers through JSPI technology, introducing the run_sync() function to implement stack switching mechanisms, allowing synchronous Python code to call asynchronous JavaScript without modifying the entire call stack.
The author advocates writing toy programs to rediscover programming joy, following the 80:20 principle to implement core functionality with minimal code. The article shares 20 suitable practice toy projects, including regex engines, operating system kernels, game emulators, and compilers, with each project annotated with difficulty and time estimates.
Analyzes the advantages, disadvantages, and development trends of current mainstream AI programming tools (Cursor, GitHub Copilot, Claude Code, Amp, OpenAI Codex, Devin, v0, etc.).
Compares different programming assistant tools (such as Cursor and Claude Code) in terms of code understanding and generation quality experience, summarizing practical Vibe Coding techniques such as precise goal decomposition, providing key inputs, timely intervention, and making good use of planning mode. (Additional: Another AI-assisted programming experience sharing How I Vibe Coding?)
Projects & Resources
× 13A curated navigation site for high-quality Python resources, including newsletters, communities, blogs, and podcasts, currently featuring 738 entries. (PS: This is a personal project by the author of this newsletter. Most of the articles from these websites have appeared in our newsletter, making it a valuable collection of Python learning websites worth bookmarking.)
A terminal browser that rewrites web pages into Markdown format through AI, supporting custom prompts and view configurations, enabling comfortable web browsing even in the command line.
An AI automation tool that lets computers work autonomously using natural language. Built on OmniParser, it can understand requirements and automatically plan tasks, intelligently understand screen content, and simulate human vision and operations. (3.5K stars)
An intelligent programming tool officially launched by Anthropic, supporting execution of routine tasks, explaining complex code, and handling git workflows. Can be used in terminals, IDEs, or GitHub. (17.3K stars)
A powerful e-book to audiobook conversion tool supporting voice cloning and over 1110 languages. Uses multiple TTS engines including XTTSv2, Bark, Vits, and Fairseq to convert e-books into high-quality audiobooks with chapters and metadata. (10.5K stars)
AWS's official MCP service suite, providing AI applications with access to AWS documentation, contextual guidance, and best practices through MCP, supporting cloud-native development, infrastructure management, and development workflows. (4.4K stars)
A comprehensive tutorial on large language model principles and practice from scratch, starting from basic NLP concepts, diving deep into Transformer architecture and pre-trained language models, providing a complete workflow for hands-on LLaMA2 model implementation, covering the entire process from pre-training to fine-tuning, as well as cutting-edge applications like RAG and Agent. (7.7K stars)
A PowerPoint operation MCP server based on python-pptx, providing 32 powerful tools supporting PPT creation, editing, and manipulation, with professional design features, chart data visualization, image processing, and shape creation capabilities.
A modern Django management dashboard with beautiful UI, powerful filtering capabilities, and fine-grained permission control.
An open-source framework for implementing dynamic memory for AI agents, replacing traditional RAG systems with scalable ECL pipelines. Supports connecting and retrieving past conversations, documents, images, and audio transcriptions, with data ingestion from 30+ data sources. (6.1K stars)
A scalable asynchronous API template using FastAPI, Pydantic V2, SQLAlchemy 2.0, PostgreSQL, and Redis. Provides complete user authentication, caching, task queues, pagination support, and other features, equipped with a modern management interface, supporting Docker deployment and NGINX load balancing. (1.2K stars)
Supports integration with multiple LLM services, providing extremely fast search speeds and intelligent agent architecture, claiming to be faster than perplexity search.
A versatile Python toolkit providing enterprise-level API gateway functionality for Python web applications, including caching, rate limiting, retry logic, timeout control, and performance monitoring, with a visualization dashboard.