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


Oracle Database 23ai - Feel the Difference
27/05/2024

The Empire strikes back with the most advanced
Oracle version to date. The focus of this new version is surprise, surprise, AI , which is so embedded into the new product that Oracle found prudent [ ... ]



Free Courses On Becoming A Data Analyst
21/05/2024

Microsoft has launched several, free, self-paced courses on Data Analysis using its Power BI suite.


More News

raspberry pi books

 

Comments




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

Last Updated ( Thursday, 21 September 2023 )