Python Weekly (Issue 630 December 14 2023)

Python Weekly - Issue 630

Python Weekly

Welcome to issue 630 of Python Weekly. Let's get straight to the links this week.

From Our Sponsor 

A weekly newsletter featuring the best hand curated news, articles, tutorials, talks, tools and libraries etc for programmers.

Articles, Tutorials and Talks

Learn how to use vector search and embeddings to easily combine your data with large language models like GPT-4. You will first learn the concepts and then create three projects.

PEP 593 is a bit vague on how you’re supposed to actually consume arguments to Annotated; here is my proposal.

At Discord, their Python test suite suffered from slow local test runs, taking 13 seconds per test. They built a pytest daemon that improves local test iteration speed by 10x, significantly reducing development time. This solution involves offloading heavy work to a background process and caching results, bypassing slow imports and fixtures.

Understand the mechanics of dynamic dispatch implementation in CPython.

The article discusses the use of conditional imports in Python, particularly the if TYPE_CHECKING pattern, to address differences in typechecking enforced by tools like mypy and typechecking at runtime. It explores the need for this pattern when dealing with large sets of custom classes that depend on each other and could result in circular dependencies.

The article discusses the use of the fanout pattern in the context of Celery tasks, where a single task can be replaced with a variable number of other tasks. It provides a practical example of the fanout pattern and its application in handling complex task signatures, emphasizing its power in task design and management within the Celery framework. The fanout pattern is illustrated through code examples, demonstrating its ability to handle sequential and parallel task execution, offering insights into its effectiveness for task orchestration and workload distribution

Let’s look at how to use nh3 for HTML sanitisation in Django forms. You can adapt this approach to other situations, such as in DRF serializers.

Python 3.10 introduced structural pattern matching, known as match/case, which allows for matching patterns in the structure of data. The article provides a real-world example of using match/case to simplify the examination of complex JSON payloads received from a GitHub bot, demonstrating its practical application in handling deeply nested data structures. The author highlights how match/case made the task much simpler compared to traditional methods of picking apart the payloads

Interesting Projects, Tools and Libraries

Build and iterate on your UI 10x faster with AI - right from your own IDE.

µHTTP emerged from the need of a simple web framework. It's great for micro-services, single page applications, AND monolithic monsters.

Set of tools to assess and improve LLM security.

Arrest is a small utility to easily structure and validate your REST api calls using pydantic and httpx.

An LLM Compiler for Parallel Function Calling.

A Production-ready Reinforcement Learning AI Agent Library brought by the Applied Reinforcement Learning team at Meta.

Mamba-Chat is the first chat language model based on a state-space model architecture, not a transformer.

Netchecks is a set of tools for testing network conditions and asserting that they are as expected.

A library for generative social simulation.

Intuitive, easy CLIs based on python type hints.

Single source of truth with requirements for pip and conda.

New Releases

This release includes the following announcements:

  • Configurable debugging options added to Run button menu

  • Show Type Hierarchy with Pylance

  • Deactivate command support for automatically activated virtual environments in the terminal

  • Setting to turn REPL Smart Send on/off and a message when it is unsupported

Our Other Newsletters

 - A free weekly newsletter for programmers.

- A free weekly newsletter for entrepreneurs featuring best curated content, must read articles, how to guides, tips and tricks, resources, events and more.