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. In addition to the resources linked above, you can also check out the following:
- Tutorial: Python 3.13: Cool New Features for You to Try
- Video Course: What’s New in Python 3.13
- Podcast: The Real Python Podcast - Episode #223: Exploring the New Features of Python 3.13
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.
Note: The norwegianblue
project provides a neat command-line tool that you can use to keep track of support information for many projects as provided by endoflife.date. If you install the package with pipx, you can keep up with different Python versions:
$ eol python
cycle │ release │ latest │ latest release │ support │ eol
──────┼────────────┼─────────┼────────────────┼────────────┼───────────
3.12 │ 2023-10-02 │ 3.12.7 │ 2024-10-01 │ 2025-04-02 │ 2028-10-31
3.11 │ 2022-10-24 │ 3.11.10 │ 2024-09-07 │ 2024-04-01 │ 2027-10-31
3.10 │ 2021-10-04 │ 3.10.15 │ 2024-09-07 │ 2023-04-05 │ 2026-10-31
3.9 │ 2020-10-05 │ 3.9.20 │ 2024-09-06 │ 2022-05-17 │ 2025-10-31
3.8 │ 2019-10-14 │ 3.8.20 │ 2024-09-06 │ 2021-05-03 │ 2024-10-31
3.7 │ 2018-06-27 │ 3.7.17 │ 2023-06-05 │ 2020-06-27 │ 2023-06-27
3.6 │ 2016-12-23 │ 3.6.15 │ 2021-09-03 │ 2018-12-24 │ 2021-12-23
3.5 │ 2015-09-13 │ 3.5.10 │ 2020-09-05 │ False │ 2020-09-30
3.4 │ 2014-03-16 │ 3.4.10 │ 2019-03-18 │ False │ 2019-03-18
3.3 │ 2012-09-29 │ 3.3.7 │ 2017-09-19 │ False │ 2017-09-29
3.2 │ 2011-02-20 │ 3.2.6 │ 2014-10-12 │ False │ 2016-02-20
2.7 │ 2010-07-03 │ 2.7.18 │ 2020-04-19 │ False │ 2020-01-01
3.1 │ 2009-06-27 │ 3.1.5 │ 2012-04-06 │ False │ 2012-04-09
3.0 │ 2008-12-03 │ 3.0.1 │ 2009-02-12 │ False │ 2009-06-27
2.6 │ 2008-10-01 │ 2.6.9 │ 2013-10-29 │ False │ 2013-10-29
Using eol
, short for end-of-life, you’ll get an overview of different Python versions and their support periods.
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:
>>> 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:
The figure shows the closing price of certain stocks over time. Note that you accessed hvPlot through the .hvplot
accessor.
Note: The data in stocks.parquet
is based on the stock market dataset from Kaggle, available under a Creative Commons license.
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]
.
Note: Vega is a visualization grammar, a language for specifying interactive visualizations in JSON. Altair provides a Python interface to Vega-Lite, which is a high-level grammar of graphics built on top of Vega.
The new Altair integration is even more straightforward to use:
>>> 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:
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:
- Sheena O’Connell: Power to the People who Teach the People
- Mario Munoz: How To Be A Developer and Other Lies We Tell Ourselves
- Natalia Bidart: The Fellowship of the Pony
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!