Blackfire supports Python 3.12

By Thomas di Luccio, on Nov 08, 2023

Python 3.12 is packed with fascinating features and optimizations that make the coding experience smoother, offering an array of powerful tools for developers to play around with. Let’s dive into the key cool new features of Python 3.12!

Enhanced f-string parsing:

In Python 3.12, f-string parsing has become more flexible, permitting numerous previously disallowed functionalities. This enhancement is thanks to PEP 701, which brings in a breath of fresh air for developers fond of f-strings for string formatting.

from datetime import date
major = 1
minor = 18
>>> release = date(2023, 10, 18)
>>> f"Blackfire Python probe {major}.{minor + 1}.0 supporting Python 3.12  has been released on {release:%B %-d}"
'Blackfire Python probe 1.19.0 supporting Python 3.12 has been released on October 18'

Improved error messages:

The tradition of improving error messages continues with Python 3.12, where more exceptions potentially caused by typos now provide suggestions to the user. This is a small but significant step towards making Python more user-friendly, especially for newcomers.

>>> import foo from bar
  ...
    import foo from bar
    ^^^^^^^^^^^^^^^^^^^
SyntaxError: Did you mean to use 'from ... import ...' instead?
>>> from math import py
Traceback (most recent call last):
  ...
ImportError: cannot import name 'py' from 'math'. Did you mean: 'pi'?

Performance improvements

Python 3.12 boasts numerous large and small performance improvements, such as the support for the BOLT binary optimizer. These optimizations collectively deliver an estimated 5% overall performance improvement, making Python 3.12 faster and more efficient​. (PEP 709).

Linux perf profiler support:

Adding support for the Linux perf profiler to report Python function names in traces is a significant enhancement for developers working on Linux platforms. This feature will aid in better performance analysis and debugging​1​.

Buffer protocol support:

Another noteworthy feature is supporting the buffer protocol in Python code (PEP 688). This support facilitates more efficient handling of buffer-enabled objects, enhancing the overall performance and capabilities of Python programs.

Embrace Python 3.12

Python 3.12 contains many more great features worth exploring. Make sure to get the latest version of the Blackfire probe and try it out.

To better observability and beyond!

Thomas di Luccio

Thomas is a Developer Relations Engineer at Platform.sh for Blackfire.io. He likes nothing more than understanding the users' needs and helping them find practical and empowering solutions. He’ll support you as a day-to-day user.