Posted On: Sep 2, 2021

Amazon Web Services Lambda now supports Python 3.9 in the Amazon Web Services China (Beijing) Region, Operated by Sinnet, and the Amazon Web Services China (Ningxia) Region, Operated by NWCD. You can now author Amazon Lambda functions in Python 3.9 and use its new features, such as support for TLS 1.3, new string and dictionary operations, and improved time zone support. Python 3.9 also includes performance optimizations that you can benefit from without making any code changes.

Python 3.9 also introduces some changes to the Lambda programming model for Python. Starting with Python 3.9, if you deploy your function handler as a Python package, Lambda now runs code in the file to initialize that package when it is imported. Also, Lambda now includes the requestId of the invoke when it returns an error response. To learn more about writing functions in Python 3.9, see the Python programming model in the Lambda documentation.

To deploy Lambda functions using Python 3.9, upload the code through the Lambda console and select the Python 3.9 runtime. You can also use the Amazon CLI, Amazon Serverless Application Model (Amazon SAM) and Amazon CloudFormation to deploy and manage serverless applications written in Python 3.9. Additionally, you can also use the Amazon Web Services-provided Python 3.9 base image to build and deploy Python 3.9 functions using a container image. To migrate existing Lambda functions running earlier Python versions, update your code to be compatible with Python 3.9 and then update the function runtime to Python 3.9.

Python 3.9 is the latest release of Python and will be supported for security and bug fixes until October 2025. Lambda will automatically apply updates to the Python 3.9 managed runtime and to the Python 3.9 Amazon Web Services -provided base image, as they become available from the Python community.

The Python 3.9 runtime in Amazon Web services Lambda is now available in the Amazon Web Services China (Beijing) Region, operated by Sinnet and Amazon Web Services China (Ningxia) Region, operated by NWCD. Visit our product page for more information about Amazon Lambda or sign in to the Amazon Lambda console to get started.