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.


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:

# Copy function code

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.


Microsoft Windows Announced 40 Years Ago

Although it didn't launch until 1985, Microsoft Windows was announced in November 1983. It signaled the move for users from the command line to a GUI environment, something that some programmers still [ ... ]

VS Code Gets Better At Make C/C++

VS Code is a "go-anywhere, work-with-anything" dev system. However, not all languages are created equal and build systems for C/C++ are particularly challenging. The latest VS Code does something to m [ ... ]

More News




or email your comment to:

Last Updated ( Thursday, 21 September 2023 )