Python 3.15 adds explicit lazy imports with the lazy keyword
Python 3.15.0, released on 9 October 2026, introduces lazy imports under PEP 810: lazy import loads a module only when its name is first used. In a test, a script with a slow module started in 0.00s instead of 0.50s, with the module loading later on demand.
- Syntax: lazy import json and lazy from pathlib import Path
- lazy is a soft keyword, so lazy = 5 still works as a variable
- Not allowed inside functions, try/except blocks or star imports
- Missing modules raise errors at first use, not at the import line
Read next
Software