Skip to content

Python Version Guides

Different Python versions have made various optimizations and changes that affect complexity characteristics.

Version Overview

Version Release Status Notes
3.14 Oct 2025 Bugfix Max-heap support, incremental GC
3.13 Oct 2024 Bugfix Free-threading (experimental)
3.12 Oct 2023 Security Better specialization
3.11 Oct 2022 Security Inline caching, 10-60% faster
3.10 Oct 2021 Security Pattern matching
3.9 Oct 2020 EOL Type hints, new parsers
3.8 Oct 2019 EOL Assignment expressions (walrus)
  • Python 3.14 - Latest: max-heap functions, better GC pauses
  • Python 3.13 - Experimental free-threading, JIT compiler
  • Python 3.12 - Comprehension inlining, type parameters
  • Python 3.11 - Significant performance improvements (inline caching)
  • Python 3.10 - Pattern matching additions
  • Python 3.9 - Type hints and parser improvements

Key Changes by Version

Python 3.14 (October 2025)

New max-heap support and optimizations:

import heapq

# Native max-heap functions (new!)
data = [3, 1, 4, 1, 5, 9]
heapq.heapify_max(data)        # O(n) - max-heap transform
heapq.heappush_max(data, 10)   # O(log n)
max_val = heapq.heappop_max(data)  # O(log n)

# Incremental GC: 10x better pause times for large heaps
# uuid4(): ~30% faster

Python 3.13 (October 2024)

Experimental features and optimizations:

# Experimental free-threading (no GIL)
# Build with: --disable-gil

# Experimental JIT compiler
# Enable with: PYTHON_JIT=1

# textwrap.indent(): 30% faster for large input

Python 3.12 (October 2023)

New features and optimizations:

# Improved error messages
"test"[999]  # IndexError with better message

# Type parameter syntax (PEP 695)
def greet[T: str](x: T) -> T:
    return x

# Performance: 5-10% faster on average

Python 3.11 (October 2022)

Major performance improvements:

# Exception groups and except* syntax
try:
    ...
except ExceptionGroup as eg:
    raise eg.derive(...)

# Inline caching for attributes
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

p = Point(1, 2)
# First access: cache miss
print(p.x)
# Repeated access: uses inline cache (much faster)

# 10-60% performance improvement overall

Python 3.10 (October 2021)

Pattern matching:

# Structural pattern matching
match value:
    case 1:
        print("one")
    case 2:
        print("two")
    case _:
        print("other")

Python 3.9 (October 2020)

Type hints and flexibility:

# Type hints without import
def add(a: list[int], b: list[int]) -> list[int]:
    return [x + y for x, y in zip(a, b)]

# Dictionary operations
d1 = {'a': 1}
d2 = {'b': 2}
d3 = d1 | d2  # {'a': 1, 'b': 2}
d1 |= d2  # Update in place

Python 3.8 (October 2019)

Assignment expressions:

# Walrus operator :=
if (n := len(a)) > 10:
    print(f"List too long ({n} elements)")

# Positional-only parameters
def func(x, /, y):
    # x is positional-only, y can be keyword
    pass

Compatibility Considerations

End of Life Dates

Version EOL Date
3.14 Oct 2030
3.13 Oct 2029
3.12 Oct 2028
3.11 Oct 2027
3.10 Oct 2026
3.9 Oct 2025 (EOL)
3.8 Oct 2024 (EOL)

Plan upgrades before EOL.

Breaking Changes

Generally minimal between minor versions, but check:

Performance Recommendations

Upgrade Path

Python 3.8 → Python 3.9    Incremental improvements
Python 3.9 → Python 3.10   Minor improvements
Python 3.10 → Python 3.11  10-60% faster (significant!)
Python 3.11 → Python 3.12  5-10% faster
Python 3.12 → Python 3.13  Similar (experimental features)
Python 3.13 → Python 3.14  Better GC pauses, new heapq functions

Recommendation: Use Python 3.11+ for performance, 3.14+ for new heapq max-heap functions.

Feature by Version

Feature Version Status
Walrus operator 3.8+ Stable
Type hints (generic) 3.9+ Stable
Pattern matching 3.10+ Stable
Inline caching 3.11+ Stable
Exception groups 3.11+ Stable
Type parameters 3.12+ Stable
Comprehension inlining 3.12+ Stable
Free-threading 3.13+ Experimental
JIT compiler 3.13+ Experimental
Max-heap (heapq) 3.14+ Stable
Incremental GC 3.14+ Stable

Complexity Characteristics by Version

Dict Operations

Version Behavior Complexity
3.5 Unordered O(1) lookup
3.6 (CPython) Ordered (implementation detail) O(1) lookup
3.7+ Ordered (language guarantee) O(1) lookup
3.9+ Optimized O(1) lookup (faster)

List Operations

Version Append Insert Notes
All 3.x O(1)* O(n) Consistent

String Operations

Version Lookup Contains Notes
3.3+ O(1) O(n + m) worst for long strings, O(n*m) worst for pathological cases Flexible representation
3.11+ O(1) O(n + m) worst for long strings, O(nm) worst for pathological cases Faster due to inline caching

Upgrading Python

Check Compatibility

# Test with newer version
uv python install 3.12
uv run --python 3.12 pytest  # Run tests

# Check for deprecations
uv run --python 3.12 python -W all your_script.py

Gradual Adoption

# Pin version for this project
echo "3.11" > .python-version
uv sync  # Installs Python 3.11 and dependencies

# Use different version for one-off commands
uv run --python 3.12 python script.py