Python 3.8 Page

Python 3.8



Return to Python Versions, Python Version History, Python, Python DevOps




PEPs Implemented in Python 3.8



Python 3.8 introduced several important features and enhancements, guided by various Python Enhancement Proposals (PEPs). These updates focused on improving language flexibility, performance, and developer experience. Below is a list of the key PEPs implemented in Python 3.8, along with raw URLs for each proposal. As with previous versions, these PEPs are critical to evolving Python, similar to how standards like RFC 7231 guide web protocols like HTTP.

PEP 572 introduced the "walrus operator" (`:=`), allowing assignment expressions within expressions. This feature enables developers to assign values to variables as part of larger expressions, improving readability and making code more concise. The "walrus operator" is especially useful in loops and conditional statements where the result of an expression needs to be used repeatedly. More details can be found at https://peps.python.org/pep-0572/.

PEP 570 adds positional-only parameters to function definitions, improving the flexibility of function signatures. This allows developers to specify that certain function arguments must be passed positionally and cannot be passed as keyword arguments. Positional-only parameters provide more control over function interfaces, especially in libraries where argument names are not part of the public API. Learn more at https://peps.python.org/pep-0570/.

PEP 574 introduces "pickle protocol 5," which adds support for out-of-band data buffers in the `pickle` module. This allows large objects to be serialized more efficiently by separating their data into distinct buffers, improving performance for certain serialization use cases, especially when working with large binary data. More information can be found at https://peps.python.org/pep-0574/.

PEP 587 introduces a new C-API for initializing Python interpreters, giving developers more control over the initialization process of embedded interpreters. This change improves flexibility for applications that embed Python and need to customize interpreter settings before execution. The new API provides better management of global runtime settings and allows more sophisticated initialization workflows. See more at https://peps.python.org/pep-0587/.

PEP 590 introduces the "vectorcall" protocol, which improves the performance of function calls by optimizing how arguments are passed to functions. The new protocol reduces overhead in calling functions, especially in scenarios involving frequently invoked functions or built-in methods. Vectorcall is part of ongoing efforts to improve Python's performance, particularly in tight loops or computational-heavy code. More details are available at https://peps.python.org/pep-0590/.

PEP 578 improves security by enhancing auditing capabilities in Python's runtime. This PEP introduces a framework for auditing events that occur within the runtime, allowing applications and frameworks to monitor sensitive operations like file access or subprocess execution. This feature provides better transparency and security in Python applications, especially for environments where auditing and logging are critical. Learn more at https://peps.python.org/pep-0578/.

PEP 586 introduces "literal types," allowing developers to specify specific literal values as valid types for type hints. This feature enhances the expressiveness of type hints, especially when defining constants or configuration flags with predefined valid values. Literal types help improve static analysis and type checking, making Python code safer and more predictable. See more at https://peps.python.org/pep-0586/.

PEP 589 adds support for TypedDict, a way to define dictionary objects with a fixed set of keys and corresponding types for their values. This feature enables more precise type annotations for dictionaries, improving static type checking when working with structured data, such as JSON or configuration files. TypedDict enhances the expressiveness of type annotations, making code involving dictionaries more robust and maintainable. More information can be found at https://peps.python.org/pep-0589/.

PEP 591 introduces the `Final` qualifier, which allows developers to specify that certain classes, methods, or variables should not be overridden or reassigned. This feature is useful in cases where immutability or finality is critical to maintaining the integrity of an API or object model. By marking certain elements as `Final`, developers can ensure that they remain unchanged, improving code safety and reducing bugs. See more details at https://peps.python.org/pep-0591/.

PEP 592 introduces the `Protocol` class, which allows developers to define structural subtyping for Python classes. This feature is particularly useful in typing scenarios where duck typing is common, allowing developers to define expected behaviors (i.e., methods and attributes) without needing to explicitly inherit from a particular class. The `Protocol` class improves the flexibility of type checking and code reuse in large codebases. More information is available at https://peps.python.org/pep-0592/.

Conclusion



Python 3.8 introduced a variety of important features that significantly improve both the flexibility and performance of the language. From the introduction of the "walrus operator" via PEP 572 to enhancements in typing and serialization, this release adds powerful tools for developers working across a wide range of applications. These changes, driven by key PEPs, reflect Python's continued evolution as a flexible and high-performance language. For more details on the updates in Python 3.8, refer to the official documentation at https://docs.python.org/3.8/whatsnew/3.8.html.


{{navbar_python}}

{{navbar_python}}

{{navbar_footer}}