SlideShare a Scribd company logo
1 of 31
What’s new in Python
3.11
Anthony Shaw
@anthonypjshaw
Hello!
@anthonypjshaw
tonybaloney.github.io
For more details on the guts of
Python, checkout my book
“CPython Internals”
Wait, 3.11?
3.0
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10
3.11
3.12
Alpha releases
Beta release
First Stable
release of 3.x
ASync
Type Annotations
F-strings
Typing
improvements
Performance
improvements
What did I miss in Python 3.10?
Match statements!
Installing Python 3.11
MacOS and Linux Users use
python.org:
Windows Users use the Store:
Tip: Don’t compile from source unless you
know how to configure profile and linker
optimization
Changes to exceptions and
error handling
Better exception messages
* Not yet supported in IPython
Exception Groups
add_note is a new
feature in Python
3.11
Raise ExceptionGroup
Exception Groups Tracing
Extracting Exceptions from Groups
except*
ExceptionType
New
syntax
Exception is a collection of
exceptions
New exception
type
Asyncio Task Groups
• Replacement for gather()
API
• Exceptions are raised as an
Exception Group.
Typing Updates
Self is now a type
• Ideal for class methods,
like factories
• Great for inheritance
Classes than inherit from Person, calls to
from_db() will return an instance of that
class, not the base class.
Variadic Generics
Data class transforms
Implement your own versions of dataclass and get native support for type checkers and IDEs.
Checkout Dave Beazleys’s minimal “dataklass” library for a good example of using this.
Already available as a backport and implemented in Pydantic.
New modules
TOMLlib
Implements a very basic TOML
library for reading TOML files.
Only has 2 methods
- load (f)
- loads(s)
NB: open files in binary mode!
Performance Improvements
Impact
Code Changes
Less
More
More
Less
Rewrite in Cython
Implement in PyPy
Optimize Existing Code
Caching Tiers
Scale-out Infrastructure
Minor-Version Python
Upgrades
Optimize DB/IO
Selecting a Profiler
Type Level Multi
process
Asyncio Python Support
austin Sampler line ✔︎ ✔︎ 3.7-3.10
scalene Sampler line ✔︎ ✔︎ 3.8-3.10
cProfile Tracing function 2-3.11
pyinstrument Sampling function ✔︎ ✔︎ 3.7-3.10
Py-spy Sampling function ✔︎ ✔︎ 2-3.10
yappi Tracing function ✔︎ ✔︎ 2-3.10
Scalene in action
Specializing Adaptive Interpreter
• Python is highly dynamic, making optimizations difficult
• PEP659, the Specializing Adaptive Interpreter is part of
the work to make Python 4x faster over the next few
releases.
Assorted performance updates
• Exception handling goes from 10-15% overhead to 1%
overhead
• Regular expressions are ~10% faster
• Function calls have a smaller overhead
Realistic Benchmark results
-20%
-50%
-60%
Delta Blue benchmark uses:
- Classes, method calls and class methods
- Loops
-30%
-20%
-60%
Richards benchmark uses:
- Classes, method calls and class methods
- Loops
Math Benchmark results
-20%
-50%
-60%
Nbody benchmark uses:
- Tight, nested loops
- Floating point arithmetic
If your code is float-heavy, this is a good
representation
JSON serialization
Serialize Deserialize
What does this mean for me?
• Expect ~20-30% performance improvement in most
applications
• Benchmark your code
• Transition from 3.9 – 3.11 could show a 2x performance gain
What can we expect in the future?
• More performance improvements!
• Python 3.12 is already being worked on
• Lazy Imports
• Per interpreter GIL (was called sub-interpreters)
• Python 3.13, 3.14 and 3.15 are scheduled for the next 3 years
• There is no mention of Python 4 (yet)
Summary
1. Start testing soon so you’re ready to upgrade
2. Benchmark your code so you can share the performance
differences
3. Checkout gradual typing if you haven’t already

More Related Content

What's hot

4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
Juraj Hantak
 
Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...
Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...
Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...
confluent
 

What's hot (20)

Pcapngを読んでみる
Pcapngを読んでみるPcapngを読んでみる
Pcapngを読んでみる
 
Develop and Build OSGi Bundles Without Pain Using IntelliJ and Gradle
Develop and Build OSGi Bundles Without Pain Using IntelliJ and GradleDevelop and Build OSGi Bundles Without Pain Using IntelliJ and Gradle
Develop and Build OSGi Bundles Without Pain Using IntelliJ and Gradle
 
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
 
Everything You Always Wanted to Know About Kafka’s Rebalance Protocol but Wer...
Everything You Always Wanted to Know About Kafka’s Rebalance Protocol but Wer...Everything You Always Wanted to Know About Kafka’s Rebalance Protocol but Wer...
Everything You Always Wanted to Know About Kafka’s Rebalance Protocol but Wer...
 
Ansible ではじめる ネットワーク自動化(Ansible 2.9版)
Ansible ではじめる ネットワーク自動化(Ansible 2.9版)Ansible ではじめる ネットワーク自動化(Ansible 2.9版)
Ansible ではじめる ネットワーク自動化(Ansible 2.9版)
 
libpgenでパケット操作
libpgenでパケット操作libpgenでパケット操作
libpgenでパケット操作
 
ConfD で Linux にNetconfを喋らせてみた
ConfD で Linux にNetconfを喋らせてみたConfD で Linux にNetconfを喋らせてみた
ConfD で Linux にNetconfを喋らせてみた
 
WebRTC配信とハードウェアエンコーダ
WebRTC配信とハードウェアエンコーダWebRTC配信とハードウェアエンコーダ
WebRTC配信とハードウェアエンコーダ
 
NETCONFとYANGの話
NETCONFとYANGの話NETCONFとYANGの話
NETCONFとYANGの話
 
Fluentd vs. Logstash for OpenStack Log Management
Fluentd vs. Logstash for OpenStack Log ManagementFluentd vs. Logstash for OpenStack Log Management
Fluentd vs. Logstash for OpenStack Log Management
 
Cilium + Istio with Gloo Mesh
Cilium + Istio with Gloo MeshCilium + Istio with Gloo Mesh
Cilium + Istio with Gloo Mesh
 
InterPlanetary File System (IPFS)
InterPlanetary File System (IPFS)InterPlanetary File System (IPFS)
InterPlanetary File System (IPFS)
 
監視 Overview
監視 Overview監視 Overview
監視 Overview
 
Scaling WebRTC applications with Janus
Scaling WebRTC applications with JanusScaling WebRTC applications with Janus
Scaling WebRTC applications with Janus
 
CommCon 2023 - WebRTC & Video Delivery application security - what could poss...
CommCon 2023 - WebRTC & Video Delivery application security - what could poss...CommCon 2023 - WebRTC & Video Delivery application security - what could poss...
CommCon 2023 - WebRTC & Video Delivery application security - what could poss...
 
Module 4: NETCONF Tutorial
Module 4: NETCONF Tutorial Module 4: NETCONF Tutorial
Module 4: NETCONF Tutorial
 
Introduction to IPython & Jupyter Notebooks
Introduction to IPython & Jupyter NotebooksIntroduction to IPython & Jupyter Notebooks
Introduction to IPython & Jupyter Notebooks
 
Python
PythonPython
Python
 
Intro to Jupyter Notebooks
Intro to Jupyter NotebooksIntro to Jupyter Notebooks
Intro to Jupyter Notebooks
 
Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...
Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...
Static Membership: Rebalance Strategy Designed for the Cloud (Boyang Chen,Con...
 

Similar to What's new in Python 3.11

Similar to What's new in Python 3.11 (20)

Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
What’s New In Python 3.11 & Python 3.11.3 ?
What’s New In Python 3.11 & Python 3.11.3 ?What’s New In Python 3.11 & Python 3.11.3 ?
What’s New In Python 3.11 & Python 3.11.3 ?
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. tx
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
 
Learn python
Learn pythonLearn python
Learn python
 
Python Version 3.7
Python Version 3.7Python Version 3.7
Python Version 3.7
 
Faster Python Programs Through Optimization by Dr.-Ing Mike Muller
Faster Python Programs Through Optimization by Dr.-Ing Mike MullerFaster Python Programs Through Optimization by Dr.-Ing Mike Muller
Faster Python Programs Through Optimization by Dr.-Ing Mike Muller
 
Moving to Python 3
Moving to Python 3Moving to Python 3
Moving to Python 3
 
Australian Bioinformatics Conference (ABiC) 2014 Talk - Doing bioinformatics ...
Australian Bioinformatics Conference (ABiC) 2014 Talk - Doing bioinformatics ...Australian Bioinformatics Conference (ABiC) 2014 Talk - Doing bioinformatics ...
Australian Bioinformatics Conference (ABiC) 2014 Talk - Doing bioinformatics ...
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Python
PythonPython
Python
 
Basics of python
Basics of pythonBasics of python
Basics of python
 
Introduction to python3.pdf
Introduction to python3.pdfIntroduction to python3.pdf
Introduction to python3.pdf
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
 
Python Evolution
Python EvolutionPython Evolution
Python Evolution
 
Python Developer Certification
Python Developer CertificationPython Developer Certification
Python Developer Certification
 
Python-IT-Education-Centre-Syllabus.pdf
Python-IT-Education-Centre-Syllabus.pdfPython-IT-Education-Centre-Syllabus.pdf
Python-IT-Education-Centre-Syllabus.pdf
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
INTERNSHIP REPORT.docx
 INTERNSHIP REPORT.docx INTERNSHIP REPORT.docx
INTERNSHIP REPORT.docx
 
Python Tutorial for Beginner
Python Tutorial for BeginnerPython Tutorial for Beginner
Python Tutorial for Beginner
 

More from Anthony Shaw (6)

I can count to 1023
I can count to 1023I can count to 1023
I can count to 1023
 
Python 3.8 and Beyond
Python 3.8 and BeyondPython 3.8 and Beyond
Python 3.8 and Beyond
 
Pyjion - a JIT extension system for CPython
Pyjion - a JIT extension system for CPythonPyjion - a JIT extension system for CPython
Pyjion - a JIT extension system for CPython
 
Docker and Containers in the Cloud
Docker and Containers in the CloudDocker and Containers in the Cloud
Docker and Containers in the Cloud
 
Introducing container as-a-service support to apache libcloud
Introducing container as-a-service support to apache libcloudIntroducing container as-a-service support to apache libcloud
Introducing container as-a-service support to apache libcloud
 
Apache LibCloud - Keeping up with the cloud market in 2016
Apache LibCloud - Keeping up with the cloud market in 2016Apache LibCloud - Keeping up with the cloud market in 2016
Apache LibCloud - Keeping up with the cloud market in 2016
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

What's new in Python 3.11

Editor's Notes

  1. GPU reporting Multiprocessing Memory trends System time, C time and Python time reporting