Recently AWS announced the support for Python 3.9 as both a managed runtime and a container base image for its Function as a Services (FaaS) offering Lambda. As a result, developers can now author AWS 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.
AWS Lambda supports multiple languages through the use of runtimes such as Java, Ruby, and Python. And for a function defined as a container image, a developer chooses a runtime (Python 3.9 base image) and the Linux distribution when creating the container image. Up until recently, Lambda supported Python 3.8. Now, the company brings support for Python 3.9 to allow developers to benefit from the features of that runtime.
With the AWS Management Console, AWS CLI, or AWS SDK, AWS Serverless Application Model (AWS SAM), or AWS Cloud Development Kit (AWS CDK), developers can develop their AWS Lambda functions using Python 3.9 runtime. Furthermore, when they want to deploy Lambda functions using Python 3.9, developers can upload the code through the Lambda console and select the Python 3.9 runtime. Or they can opt to use the AWS CLI, AWS Serverless Application Model (AWS SAM), or AWS Cloud Formation.
Source: https://aws.amazon.com/blogs/compute/python-3-9-runtime-now-available-in-aws-lambda/
With Python 3.9, there are also two significant performance improvements in Python 3.9 that developers can benefit from without making any code changes. James Beswick, a principal developer advocate for AWS Serverless, explains these improvements in a recent AWS Compute blog post on the availability of Python 3.9 runtime in AWS Lambda:
The first impacts code that uses the built-in Python data structures tuple, list, dict, set, or frozenset. In Python 3.9, these internally use the vectorcall protocol, which can make function calls faster by reducing the number of temporary objects used. Second, Python 3.9 uses a new parser that is more performant than previous versions.
Additionally, the Lambda service now runs the __init_.py code before the handler and provides enhanced logging for errors.
AWS competitors in the FaaS space, Microsoft and Google, currently also support Python 3.9 for their offering - that is, support for Python 3.9 is in preview for Azure Functions. At the same time, for Google Functions, support for Python 3.9 is generally available.
Lastly, the Python 3.9 runtime is available in all regions where Lambda is available, except for China Regions.