Python Monthly News

Python News Roundup: October 2024

by Geir Arne Hjelle Oct 07, 2024 community

October is always an important month for Python, as this is when a new major version is released. Python 3.13 is the new version this year, and it brings several new features that lay the groundwork for other changes in the future. As one version of Python comes to life, another is put to rest. Python 3.8 is already five years old, which means that this version won’t be supported any longer.

There are also exciting developments happening in the wider Python community. In this newsletter, you can read about Polars’ improved support for plotting, as well as how Django developers gathered for the annual DjangoCon US conference.

Time to jump in and read about what’s happening in the world of Python!

Python 3.13 Release Slightly Delayed

The release of Python 3.13, the newest version of Python, was originally scheduled for October 1, 2024. However, a few days before that date, release manager Thomas Wouters decided to postpone the release until October 7, 2024:

I’m a little concerned with the impact of the incremental GC change in 3.13, which recently showed up. It’s not clear that the incremental GC provides significant improvements (although the smaller pauses are probably desirable), it clearly has slightly more overhead in common cases, and we’re still discovering pathological cases.

I don’t think we should release 3.13.0 with the incremental GC. (Source)

The incremental garbage collector was a small improvement slated for Python 3.13. In many cases, the new garbage collection algorithm improves performance. Unfortunately, it was found to slow down Python significantly in some rare cases.

As a result, the core developers decided to revert the implementation and use the traditional garbage collector in Python 3.13. At the same time, the new implementation is being scrutinized and currently the goal is to include incremental garbage collection in Python 3.14.

Delaying a major Python release is never an easy choice. However, erring on the side of caution is a good approach, and it’s great to see that the Python 3.13 release is being handled responsibly.

Python 3.13 Highlights

As always, a new Python release brings many improvements and new features. You can explore these in-depth in Python 3.13: Cool New Features for You to Try. In particular, the new release includes:

  • A brand new interactive interpreter (REPL)
  • Colored tracebacks and improved error messages
  • A separate, free-threaded version of Python that runs without the global interpreter lock (GIL)
  • An experimental just-in-time (JIT) compiler
  • Several improvements to Python’s static type system

For free threading and the JIT compiler, you need to compile Python with special build flags. Read Python 3.13 Preview: Free Threading and a JIT Compiler to learn more about how to explore these two new features. Additionally, Python 3.13 Preview: A Modern REPL provides more detail on the new REPL.

In addition to these features, there are many smaller changes:

  • Command-line support for using random to quickly make random choices
  • A new copy.replace() function to make variations of immutable objects
  • Improved globbing of files and directories
  • A smaller memory footprint for docstrings

For all the details, consult Python’s changelog. You can also follow the Python 3.13 coverage on Real Python.

If you haven’t tried Python 3.13 for yourself yet, then you should take it for a test drive!

Work on Subinterpreters Continues

One of the new features in last year’s Python 3.12 was support for subinterpreters. To use subinterpreters in Python 3.12, you need to work with extension modules and Python’s C-API. The plan, as detailed in PEP 554, was to add a new interpreters module to the standard library that could be used to interact with subinterpreters through regular Python code.

Core developer Eric Snow wrote a new PEP 734 to refocus the work on subinterpreters. This PEP is a continuation of the earlier work, and has two main objectives:

  • Expose the 3.12 subinterpreter capabilities to Python code
  • Add a mechanism for communicating between interpreters

While the work took more time than planned, it’s still moving forward. Snow recently shared some progress after meeting with the Steering Council:

The plan is to have a PyPI package for 3.13+ (and maybe 3.12) that’s hosted on a cpython PyPI org. We’ll assess where things stand early next year with the goal of deciding about inclusion in 3.14. I’m hopeful, and am planning accordingly, but it isn’t guaranteed. (Source)

If you’re curious to try out subinterpreters for yourself, you can try the interpreters-pep-734 package available on PyPI. Keep in mind that this is still highly experimental, so you shouldn’t use it for anything important at this point.

Python 3.8 Reaching End-of-Life

Each version of Python comes with some guarantees of support. This is outlined in PEP 602 which describes Python’s release cycle. Since Python 3.3, each new release has been maintained and supported for five years.

Python 3.8 was released in October 2019, which means that it’s about to reach its end-of-life. Of course, Python 3.8 won’t suddenly stop working. But it will no longer receive any new security updates going forward.

If you’re still relying on Python 3.8—or older—you should look into how you can upgrade your environments. In addition to missing out on newer features in the language, you’re exposing yourself to possible insecurities that may have serious consequences.

Lightweight Plotting in Polars With Altair

Polars is a lightning-fast DataFrame library offering similar functionality as pandas, but often with better performance. Since its first release in 2021, the library has gained a lot of popularity because of its speed and consistent syntax.

Since the early days of Polars, you could convert a Polars DataFrame into pandas and use one of the many visualization libraries that support pandas to make plots. Later, Polars took advantage of the HoloViz library hvPlot to build plotting support into Polars.

You can create and save a plot based on hvPlot as follows:

Python
>>> import polars as pl
>>> import hvplot
>>> import hvplot.polars
>>> hvplot.extension("matplotlib")

>>> chart = (
...     pl.scan_parquet("stocks.parquet")
...     .filter(pl.col("Symbol").is_in(["NUM", "POL", "PYT", "RP"]))
...     .collect()
...     .hvplot
...     .line(x="Date", y="Close", by="Symbol")
... )
>>> hvplot.save(chart, "stocks.png", backend="matplotlib", dpi=300)

This results in a chart similar to the following:

A line plot showing different stocks over time, plotted using hvPlot and Polars

The figure shows the closing price of certain stocks over time. Note that you accessed hvPlot through the .hvplot accessor.

While having visualization tools readily available in Polars is great, the integration isn’t perfect. Under the hood, hvPlot converts your data to a pandas DataFrame. This means that to make these plots, you need to install several extra dependencies into your environment, including heavy lifters like pandas and NumPy.

In the recent version 1.6, Polars added support for plotting with the Vega-Altair library. In contrast to hvPlot, Altair provides native support for Polars with the help of Narwhals. You can install the necessary dependencies by issuing python -m pip install polars[plot].

The new Altair integration is even more straightforward to use:

Python
>>> import polars as pl

>>> (
...     pl.scan_parquet("stocks.parquet")
...     .filter(pl.col("Symbol").is_in(["NUM", "POL", "PYT", "RP"]))
...     .collect()
...     .plot
...     .line(x="Date", y="Close", color="Symbol")
...     .save("stocks.png", ppi=300)
... )

You access different Altair plotting tools through the .plot accessor. This results in a chart like the following:

A line plot showing different stocks over time, plotted using Altair and Polars

As before, you can follow different stocks over time. Note that if you’re working in an interactive environment like Jupyter, then you don’t need to explicitly save your chart. Instead, Jupyter can immediately display the graph inside the notebook. To do so, simply leave off the call to .save().

DjangoCon US

This year’s DjangoCon US took place in Durham, North Carolina from September 22 to 27. The conference included a day of tutorials, three days of talks, and two days of sprints, all about Django.

The DjangoCon conference has been held since 2008, with editions being held annually in both Europe and the US. In 2023, DjangoCon Africa was also held for the first time.

This year’s DjangoCon US included keynotes from:

As always, the keynotes and the other presentations were of great quality. You can subscribe to DjangoCon US’s YouTube channel to be alerted when the videos become available for everyone, probably in a few months’ time.

What’s Next for Python?

While Python 3.13 is currently generating most of the buzz in the community, there are already many new developments happening. The developers aren’t resting on their laurels, and you can expect the first alpha release of Python 3.14 in just a few weeks.

It’s great to see the language and community continue to thrive and grow. What’s your favorite Python news story from the last month? Let us know in the comments. Happy Pythoning!

🐍 Python Tricks 💌

Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

Python Tricks Dictionary Merge

About Geir Arne Hjelle

Geir Arne is an avid Pythonista and a member of the Real Python tutorial team.

» More about Geir Arne

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Master Real-World Python Skills With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

Master Real-World Python Skills
With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

What Do You Think?

Rate this article:

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal.


Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!