The article uses the Floyd-Steinberg dithering algorithm as an example to demonstrate various techniques to improve code performance, reducing the execution time from 2339 microseconds down to 554 microseconds. Some of the concepts covered include instruction-level parallelism (ILP), branch prediction, single instruction multiple data (SIMD), and memory hierarchy.
TL;DR
Speeding up Python on a single core anchors the issue, llama2.mojo proves Llama 2 runs in pure Mojo, and 146 EuroPython 2023 videos are worth bookmarking.
Articles & Tutorials
× 12A basic introductory tutorial on how to use Radon to measure the complexity of Python code, i.e., calculate metrics such as cyclomatic complexity, and introduces the use of related commands.
Brett Cannon wrote a series of blog posts about "syntactic sugar", which analyzed more than 80 syntactic sugar features. The article introduces some of them based on his PyCon talk and blog posts.
SymPy is a library for symbolic computation, which can handle problems in areas such as algebra, calculus, and discrete mathematics. This is a series of posts about major changes coming to it. The post describes the current speed problems with SymPy, the work being done to speed it up, and plans for future speed improvements. (See also: Part 2 of the series: Polynomial Evaluation in SymPy)
In terms of dependency governance, import-linter is a very useful tool. It allows us to express the implicit complex dependencies within a project explicitly through a configuration file by providing various types of "contracts". This article introduces its basic usage and six tips for fixing dependencies.
CPython uses Bloom filters for string manipulation, such as in the splitlines() and strip() functions. The article explains how these functions are implemented. It also discusses how a typical Bloom filter works and how CPython implements Bloom filters (in less than 50 lines of C code).
This article introduces several methods of the uuid library: uuid1() generates a UUID using the system MAC address and a timestamp; uuid4() generates a completely random UUID; uuid3() and uuid5() generate UUIDs based on a constant namespace and a variable name, with the former using the MD5 algorithm and the latter using the SHA-1 algorithm.
Why are there so many dataframe libraries, such as Pandas, Polars, Dask, and PySpark? The author argues that the main reason is its four role models: spreadsheet, relational database, 2D array/matrix, and object, and a series of problems derived from them.
The Monty Hall problem, also known as the three-door problem, is a probability puzzle that challenges intuitive reasoning. The article uses Python to simulate the problem to see how many times it takes to win a prize.
The article introduces six use cases for the functools standard library: @cache for caching, @total_ordering to save you from writing the rich comparison methods, partial() for freezing arguments, @singledispatch for generic functions, @wraps for decorators, and reduce() function.
pytest.main is a handy function in the Pytest framework for running test suites from the command line or programmatically. The article explores its usage and some common use cases.
Introduces seven great authentication libraries: Authlib, Pyjwt, Flask-login, Django-allauth, ItsDangerous, Python Social Auth, Flask-security. (Also available in Chinese translation.)
🎁 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 code metrics analyzer that can calculate cyclomatic complexity, raw metrics, Halstead metrics, and maintainability index, which can be used for CI integration and with Jupyter Notebook. (1.5K stars)
Autonomous Language Agents refer to intelligent agent systems that can independently perform natural language processing tasks. This library supports functions such as long-term and short-term memory, tool usage, web navigation, multi-agent communication, human-computer interaction, and symbolic control. (star 2.6K)
A library for Python multiprocessing that makes it easy to manage long-running multiprocess jobs. It handles process creation and cleanup, signal management, interprocess communication, and other hassles of dealing with multiple processes.
Generates realistic schemas and knowledge graphs given user-specified parameters, ensuring logical consistency via a DL reasoner (HermiT).
This repository mainly compares several toml libraries, including toml, tomli/tomli_w, tomlkit, pytomlpp, rtoml, and qtoml, from multiple dimensions, examining their behaviors and performance when processing data.
Given an image, segment the foreground object using Paint3D, and generate images from multiple views through inference.
Segment Anything (SAM) is a task in computer vision to segment any object in an image or video, extracting sub-regions or objects with semantic or visual characteristics.
A Chinese open-source project. It can automatically extract structured key information from unstructured log information. (1.2k stars)
The author ported the Python version of llama2.py to Mojo, which improved the performance by nearly 250 times. (1.1k stars)
A leading open-source large model application development platform, named after Bi Sheng, the inventor of movable type printing in China. It can be used to build various large model applications, such as analysis report generation, knowledge base Q&A, dialogue, and feature extraction.
Podcasts & Videos
× 2Videos of the talks from this year's EuroPython event.
Scalene is a high-performance CPU, GPU, and memory profiler that can profile code down to the individual function or line of code level and compare time spent in Python and C code. The podcast guest is a professor at the University of Massachusetts who developed Scalene with students in his lab.