AWS Lambda Adopts Python 3.11
Written by Nikos Vaggalis   
Thursday, 21 September 2023

Recently AWS Lamda switched from Python runtime 3.10 to 3.11, promising a lot of improvement. In which parts?

Back in May we had a look at Amazon's adoption of the Python 3.10 runtime intened to take advantage of the performance improvements that version introduced, in both managed runtimes and container images. Python 3.10 enabled the use of the following enhancements when building lambda functions:

  • Structural Pattern Matching
  • Parenthesized context managers
  • Better error messages
  • New Type Union Operator
  • Parameter Specification Variables
  • User-Defined Type Guards
  • Stricter Zipping
  • Automatic Text Encoding
  • Asynchronous Iteration

and provided the performance enhancements of that version, like the faster PEP 590 vectorcall calling convention which allows for quicker and more efficient Python function calls, particularly those that take multiple arguments.

The new 3.11 runtime brings additional improvements. Python 3.11 contains significant performance enhancements over Python 3.10 - like reduced startup time and streamlined stack frames, while the CPython specialization adaptive interpreter helps many workloads using Python 3.11 run faster and cheaper.

pi311aws

Talking about CPython, the related optimizations introduced in Python 3.11 makes operation an average of 25% faster than those of Python 3. 10. Along with it, Python 3.11 also provides performance-related features in the Core including:

  • String formatting with printf-style% codes is now as fast as f-string expressions.
  • Integer division is around 20% faster on x86-64 for certain scenarios.
  • Operations like sum() and list resizing have seen notable speed enhancements.
  • Dictionaries save memory by not storing hash values when keys are Unicode objects.

and more.

Of course, devs can also now take advantage of the language features added in Python 3.11:

  • Variadic generics
  • Marking individual TypedDict items as required or not-required
  • Self type
  • Arbitrary literal string type
  • Data class transforms


It is recommended that you upgrade your 3.10 based container images to the newest version by changing the Python base image version by modifying the FROM statement in the Dockerfile:

FROM public.ecr.aws/lambda/python:3.11
# Copy function code
COPY lambda_handler.py ${LAMBDA_TASK_ROOT}

or better yet get a hold of AWS's certified container images which are regularly updated with security patches and other updates and come optimized by changing the components or dependencies included in them.

 

 

More Information

Python 3.11 runtime now available in AWS Lambda

Related Articles

AWS Lambda Adopts Python 3.10

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Spider Courtship Decoded by Machine Learning
07/04/2024

Using machine learning to filter out unwanted sounds and to isolate the signals made by three species of wolf spider has not only contributed to an understanding of arachnid courtship behavior, b [ ... ]



Redis Changes License, Rival Fork Launched
03/04/2024

The developers of Redis have announced that they are changing the licensing model for the database. From now on, all future versions of Redis will be released with source-available licenses rather tha [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 21 September 2023 )