Real Python: Python News: What’s New From March 2021?


Python is a dynamic language in increasingly ways than one: Not only is it not a static language like C or C , but it’s moreover constantly evolving. If you want to get up to speed on what happened in the world of Python in March 2021, then you’ve come to the right place to get your news!

March 2021 marks a notable transpiration to the cadre of the Python language with the wing of structural pattern matching, which is misogynist for testing now in the latest alpha release of Python 3.10.0.

Beyond changes to the language itself, March was a month full of heady and historical moments for Python. The language celebrated its 30th birthday and became one of the first open-source technologies to land on flipside planet.

Let’s swoop into the biggest Python news from the past month!

Python Turns 30 Years Old

Although Python’s very lineage stage is February 20, 1991, which is when version 0.9.0 was released, March is a good month to celebrate. This March is the 20th anniversary of the Python Software Foundation, which was founded on March 6, 2001.

In its thirty years, Python has changed—a lot—both as a language and as an organization. The transition from Python 2 to Python 3 took a decade to complete. The organizational model for decision-making reverted too: The creator of the language, Guido van Rossum, used to be at the helm, but a five-person steering steering was created in 2018 to plan the later on of Python.

Happy birthday, Python! Here’s to many increasingly years 🥂

Structural Pattern Matching Comes to Python 3.10.0

Python 3.10.0 is the next minor version of Python and is expected to waif on October 4, 2021. This update will bring a big wing to the cadre syntax: structural pattern matching, which was proposed in PEP 634. You could say that structural pattern matching adds a sort of switch statement to Python, but that isn’t entirely accurate. Pattern matching does much more.

For instance, take an example from PEP 635. Suppose you need to trammels if an object x is a tuple containing host and port information for a socket connection and, optionally, a mode such as HTTP or HTTPS. You could write something like this using an ifelifelse block:

if isinstance(x, tuple) and len(x) == 2:
    host, port = x
    mode = "http"
elif isinstance(x, tuple) and len(x) == 3:
    host, port, mode = x
    # Etc…

Python’s new structural pattern matching allows you to write this increasingly cleanly using a match statement:

match x:
    case host, port:
        mode = "http"
    case host, port, mode:
    # Etc…

match statements trammels that the shape of the object matches one of the cases and binds data from the object to variable names in the case expression.

Not everyone is thrilled well-nigh pattern matching, and the full-length has received criticism from both within the cadre development team and the wider community. In the visa announcement, the steering steering undisputed these concerns while moreover expressing their support for the proposal:

We unclose that Pattern Matching is an wide-stretching transpiration to Python and that reaching consensus wideness the unshortened polity is nearly impossible. Variegated people have reservations or concerns virtually variegated aspects of the semantics and the syntax (as does the Steering Council). In spite of this, without much deliberation, … we are confident that Pattern Matching as specified in PEP 634, et al, will be a unconfined wing to the Python Language. (Source)

Although opinions are divided, pattern matching is coming to the next Python release. You can learn increasingly well-nigh how pattern matching works by reading the tutorial in PEP 636.

Python Lands on Mars

On February 18, the Perseverance Mars rover landed on Mars without a seven-month journey. (Technically, this is a February news item, but it’s so tomfool that we have to include it this month!)

Perseverance brought a wide range of new instruments and scientific experiments that will requite scientists their weightier squint at Mars yet. Perseverance relies on a host of open-source software and off-the-shelf hardware, making it the most wieldy Mars rover project to date.

Python is one of the open-source technologies living on Perseverance. It was used on-board the rover to process images and video taken during landing.

One of the most heady experiments carried by Perseverance is the Ingenuity Mars helicopter, which is a small drone stuff used to test flight in the thin Martian atmosphere. Python is one of the development requirements for the flight tenancy software, which is tabbed F’.

2020 Python Developers Survey Results Are In

The results from the 2020 Python Developers Survey conducted by JetBrains and the Python Software Foundation are in, and they show some interesting changes compared to last year’s survey.

In 2020, 94% of respondents report primarily using Python 3, which is up from 90% in 2019 and 75% in 2017. Interestingly, Python 2 still sees use among a majority of respondents in the computer graphics and game minutiae segments.

Flask and Django protract to dominate web frameworks with 46% and 43% adoption, respectively. The newcomer FastAPI was the third most popular web framework at 12% adoption—an incredible feat considering 2020 was the first year the framework appeared in the list of options.

Visual Studio Code gained 5% increasingly of the share of responses to the question “What is the main editor you use for your current Python development?” That puts Microsoft’s IDE at 29% of the share and remoter closes the gap between Visual Studio Code and PyCharm, which still tops the list at 33%.

Check out the survey results to see plane increasingly stats well-nigh Python and its ecosystem.

New Features Coming to Django 3.2

Django 3.2 will be released sometime in April 2021, and with it comes an impressive list of new features.

One major update adds support for functional indexes, which indulge you to alphabetize expressions and database functions, such as indexing lowercased text or a mathematical formula involving one or increasingly database columns.

Functional indexes are created in the Meta.indexes option in a Model class. Here’s an example well-timed from the official release notes:

from django.db import models
from django.db.models import F, Index, Value

class MyModel(models.Model):
    height = models.IntegerField()
    weight = models.IntegerField()

    class Meta:
        indexes = [
                F("height") / (F("weight")   Value(5)),

This creates a functional alphabetize tabbed calc_idx that indexes an expression that divides the height field by the weight field and then adds 5.

Support for PostgreSQL tent indexes is flipside index-related transpiration coming in Django 3.2. A covering index lets you store multiple columns in a each index. This allows queries containing only the alphabetize fields to be satisfied without an spare table lookup. In other words, your queries can be much faster!

Another notable transpiration is the wing of Admin site decorators that streamline the megacosm of custom display and action functions.

For a well-constructed list of new features coming in Django 3.2, trammels out the official release notes. Real Python freelancer Haki Benita moreover has a helpful overview article that walks you through some of the upcoming features with increasingly context and several examples.

PEP 621 Reaches Final Status

Way when in 2016, PEP 518 introduced the pyproject.toml file as a standardized place to specify a project’s build requirements. Previously, you could specify metadata only in a file. This caused some problems considering executing and reading the build dependencies requires installing some of the build dependencies.

pyproject.toml has gained popularity in the last few years and is now stuff used for much increasingly than just storing build requirements. Projects like the black autoformatter use pyproject.toml to store package configuration.

PEP 621, which was provisionally wonted in November 2020 and marked final on March 1, 2021, specifies how to write a project’s cadre metadata in a pyproject.toml file. On the surface, this might seem like a less significant PEP, but it represents a unfurled movement yonder from the file and points to improvements in Python’s packaging ecosystem.

PyPI Is Now a GitHub Secret Scanning Integrator

The Python Package Index, or PyPI, is the place to download all of the packages that make up Python’s rich ecosystem. Between the website and, PyPI generates over twenty petabytes of traffic a month. That’s over 20,000 terabytes!

With so many people and organizations relying on PyPI, keeping the alphabetize secure is paramount. This month, PyPI became an official GitHub secret scanning integrator. GitHub will now check every commit to public repositories for leaked PyPI API tokens and will disable repositories and notify their owners if any are found.

What’s Next for Python?

Python continues to grow with increasing momentum. As increasingly users turn to the language for increasingly and increasingly tasks, it’s only natural that Python and its ecosystem will protract to evolve. At Real Python, we’re excited well-nigh Python’s later on and can’t wait to see what new things are in store for us in April.

What’s your favorite piece of Python news from March? Did we miss anything notable? Let us know in the comments, and we might full-length you in next month’s Python news round-up.

Happy Pythoning!

Comments are closed.