Python Trending Weekly
ISSUE 21

Python Trending Weekly #21 (2023-09-23)

2023-09-23 Season 1

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 12 Projects 10 Media 2
🦄

Articles & Tutorials

× 12
01 Optimizing Python Code Speed on a Single Core pythonspeed.com

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.

02 Learning About Code Metrics in Python with Radon blog.pythonlibrary.org

A 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.

03 Python (mostly) is syntactic sugar lwn.net

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.

04 Welcome to the New SymPy oscarbenjamin.github.io

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)

05 Use import-linter to Make Your Python Project Architecture Cleaner piglei.com

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.

06 How CPython Uses Bloom Filters for String Manipulation codeconfessions.substack.com

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).

07 UUIDs in Python medium.com

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.

08 Why Are There So Many Python Dataframes? ponder.io

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.

09 Simulating the Monty Hall Problem in Python dataschool.io

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.

10 6 Cool Things You Can Do with the Functools Module pybit.es

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.

11 A Deep Dive into pytest.main(): Unraveling the Core Functionality of the Python Testing Framework juejin.cn

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.

12 7 Best Python Authentication Libraries You Should Use in Your Next Project python.plainenglish.io

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

× 10
01 Radon: Various Metrics for Python Code github.com

A 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)

02 agents: Open-source framework for autonomous language agents github.com

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)

agents: Open-source framework for autonomous language agents
03 quasiqueue: A multiprocessing library github.com

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.

04 pygraft: Configurable Schema and Knowledge Graph Generation github.com

Generates realistic schemas and knowledge graphs given user-specified parameters, ensuring logical consistency via a DL reasoner (HermiT).

05 toml-bench: Which toml library to use in Python? github.com

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.

06 SyncDreamer: Generating Multi-View Consistent Images from a Single-View Image github.com

Given an image, segment the foreground object using Paint3D, and generate images from multiple views through inference.

07 nanosam: SAM Models Running Real-Time with NVIDIA TensorRT github.com

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.

08 logparser: A machine learning toolkit for log parsing github.com

A Chinese open-source project. It can automatically extract structured key information from unstructured log information. (1.2k stars)

09 llama2.mojo: Pure Mojo version of Llama 2 github.com

The author ported the Python version of llama2.py to Mojo, which improved the performance by nearly 250 times. (1.1k stars)

10 bisheng: An open LLM DevOps platform github.com

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

× 2
01 146 Videos from EuroPython 2023 youtube.com

Videos of the talks from this year's EuroPython event.

02 Real Python Podcast #172: Measuring Python Performance with Scalene realpython.com

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.

ESC
↑↓ select · ↵ open175 issues