Lazy Imports (Fehlende Imports)
15 introduces lazy imports, allowing imports to be deferred until they are needed. This feature is particularly useful for large dependencies, as it can significantly reduce the startup time of a program. Lazy imports are enabled by default, and are controlled by the environment variable PYTHON_LAZY_IMPORTS. This feature is available on both the module level and can be used with the lazy keyword.
Frozendict (Unveränderliche Wörterbücher)
Frozendict is a new immutable variant of Python's built-in dict. It is designed to prevent accidental modifications to shared configurations. Frozendicts are immutable, meaning that once created, they cannot be modified, added to, or removed from. This makes them useful for configurations that are shared across different parts of a program. Frozendicts can be used as keys in other dictionaries or as elements in sets. The order of entries in a frozendict does not affect its hash value.
Sentinel (Marker Werte)
Sentinel is a new built-in type that provides a way to distinguish between a missing argument and a None argument. This is particularly useful for APIs where it is important to know whether an argument is missing or intentionally set to None. Sentinel values are named constants that are not equal to any other value, making them suitable for use as markers in APIs.
UTF-8 Mode (Standard Text Encoding)
15 introduces UTF-8 as the default text encoding. This change ensures that text operations use UTF-8, rather than falling back to the system locale. This is particularly useful for programs running on Windows, which may have implicit assumptions about the local encoding. The default UTF-8 mode does not affect existing files, but it does require explicit encoding specification for new files.
Comprehensions (Direct Unpacking)
Comprehensions in Python 3. 15 now allow unpacking of collections directly. This means that you can unpack multiple lists, sets, or dictionaries into a single list, set, or dictionary. This is particularly useful for creating complex data structures from multiple sources.
Profiling (Improved Profiling Tools)
15 includes improved profiling tools, such as profiling. tracing and profiling. tracing provides deterministic profiling, while profiling. sampling provides statistical profiling. The new profiler Tachyon is included in profiling. sampling and can be used to profile running programs without restarting them. The profiling tools are designed to be used with root or administrator privileges, as they require access to the memory of the target program.
JIT Compiler (Improved Just-In-Time Compilation)
The experimental Just-In-Time (JIT) compiler has also been improved in Python 3. The new JIT compiler, Tachyon, provides more accurate profiling data and can be used to profile running programs without restarting them.

Kommentare