← Back to list

New Python Built-In Functions You Should Know: 3.9 to 3.12

Unlocking Productivity with Modern Python Features

Dr. Shouke Wei · 2025-09-13 13:05 · 127 claps · 2.1 min read paywalled
#python #news #built-in-function #modern-features
Open on Medium ↗
Wiki topics: ⏱️ · Productivity

New Python Built-In Functions You Should Know: 3.9 to 3.12

Unlocking Productivity with Modern Python Features

Python has been evolving rapidly in recent years, and with each release, it introduces new built-in functions and modules that simplify coding, improve performance, and make daily programming tasks more intuitive. If you’re a data scientist, software engineer, or Python enthusiast, keeping up with these updates can save you time and make your code cleaner. In this article, we’ll explore some of the most practical new features from Python 3.9 to 3.12.

Python 3.9: Cleaner Strings and Time Zones

Python 3.9 introduced several small but powerful additions:

1. str.removeprefix() and str.removesuffix()

Trimming unwanted prefixes or suffixes from strings has never been easier.

text = "HelloWorld"
print(text.removeprefix("Hello"))  # Output: "World"
print(text.removesuffix("World"))  # Output: "Hello"

2. zoneinfo module

For time zone-aware applications, the new zoneinfo module provides an easy way to work with IANA time zones.

from zoneinfo import ZoneInfo
from datetime import datetime

dt = datetime(2025, 9, 12, 15, tzinfo=ZoneInfo("America/Toronto"))
print(dt)

Python 3.10: Smarter Math and Unicode Handling

Python 3.10 added new tools for math, combinatorics, and string normalization:

1. math.dist()

Compute Euclidean distance between two points in n-dimensional space.

import math
print(math.dist([1,2], [4,6]))  # Output: 5.0

2. math.perm() and math.comb()

Generate permutations and combinations efficiently.

import math
print(math.perm(5, 3))  # 60
print(math.comb(5, 3))  # 10

3. str.casefold() improvements

Enhanced Unicode normalization for case-insensitive comparisons.

print("ß".casefold())  # Output: "ss"

Python 3.11: Faster Config Parsing and Precision Math

Python 3.11 introduced features that help with performance and real-world tasks:

1. tomllib module

Read TOML configuration files natively without external libraries.

import tomllib

with open("config.toml", "rb") as f:
    config = tomllib.load(f)
print(config)

2. math.nextafter()

Get the next floating-point number after a given value toward a target.

import math
print(math.nextafter(1.0, 2.0))  # Smallest increment toward 2.0

Python 3.12: Regex Enhancements and Performance Boosts

Python 3.12 focuses on practical updates for regex, caching, and string operations:

1. re.Match.removeprefix() and re.Match.removesuffix()

Easily remove matched prefixes or suffixes from regular expression results.

2. functools.cache improvements

More efficient caching for functions and properties.

3. Optimized int.bit_count() and str.count()

Counting bits or substrings is now faster than ever.

Other Practical Utilities

  • print(..., flush=True) – Ensure real-time output.
  • enumerate(iterable, start=0) – Faster iteration with modern Python.
  • itertools.zip_longest() – Iterate over sequences of unequal length safely.

Conclusion

From string trimming to advanced math operations and efficient configuration parsing, Python 3.9–3.12 has added numerous built-in functions and modules that simplify everyday tasks. By leveraging these features, developers can write cleaner, faster, and more maintainable code. Staying up to date with these enhancements not only improves productivity but also helps you adopt Python best practices.

Summary of the most practical “new built-in functions”:

| Version | Function/Feature                                      | Use Case                          |
| ------- | ----------------------------------------------------- | --------------------------------- |
| 3.9     | `str.removeprefix`, `str.removesuffix`                | Easy string trimming              |
| 3.10    | `math.dist`, `math.perm`, `math.comb`                 | Math / combinatorics              |
| 3.11    | `tomllib`, `math.nextafter`                           | Config parsing, numeric precision |
| 3.12    | `re.Match.removeprefix/suffix`, caching optimizations | Regex handling, performance       |

메타데이터
post_id
ca1d5866ea6d
slug
new-python-built-in-functions-you-should-know-3-9-to-3-12-ca1d5866ea6d
url
https://medium.com/@shouke.wei/new-python-built-in-functions-you-should-know-3-9-to-3-12-ca1d5866ea6d
canonical_url
https://medium.com/@shouke.wei/new-python-built-in-functions-you-should-know-3-9-to-3-12-ca1d5866ea6d
author_url
https://medium.com/@shouke.wei
status
ok
fetched_at
2026-06-28 14:26:31