cover of episode Exploring the New Features of Python 3.13

Exploring the New Features of Python 3.13

2024/10/11
logo of podcast The Real Python Podcast

The Real Python Podcast

AI Deep Dive AI Chapters Transcript
People
C
Christopher Bailey
C
Christopher Trudeau
G
Geir Arne Hjelle
Topics
Christopher Bailey 概述了 Python 3.13 的主要新特性,包括改进的 REPL、可选的 GIL、实验性的 JIT 编译器以及其他一些小的改进。他强调了这些新特性对开发者的益处,并讨论了升级到 Python 3.13 的时机。 Geir Arne Hjelle 深入探讨了 Python 3.13 的新 REPL,详细介绍了其多行编辑、代码粘贴和 Tab 补全等改进,并解释了这些改进如何提升用户体验,尤其对于初学者而言。他还讨论了 Python 3.13 中的 JIT 编译器,解释了其工作原理以及在性能提升方面的潜力。此外,他还详细介绍了 Python 3.13 对静态类型系统的改进,包括弃用警告装饰器、类型参数的默认值、使用 TypeIs 缩小类型以及 TypedDict 中只读项的支持。 Christopher Trudeau 详细介绍了 Python 3.13 中可选的 GIL 和实验性的 JIT 编译器,解释了这些实验性功能的启用方式以及它们对多线程和性能的影响。他还讨论了 Python 3.13 中改进的错误信息,包括颜色编码和更具体的提示信息,并解释了这些改进如何帮助开发者更轻松地调试代码。此外,他还介绍了 Python 3.13 对 Pathlib 模块的改进,包括对文件 URI 的支持、新的 fullmatch 方法以及对 glob 和 rglob 方法的改进。 Christopher Bailey 总结了 Python 3.13 的主要新特性,并讨论了升级到 Python 3.13 的时机。他认为,对于大多数应用场景,升级到 Python 3.13 是安全的,新特性带来的好处大于风险。 Geir Arne Hjelle 详细介绍了 Python 3.13 中的一些小的性能改进,例如在保存 docstrings 之前去除多余的空格,以及对 importlib.resources 模块的改进,使其能够处理目录。他还提到了 Python 3.13 对 iOS 和 Android 平台的支持得到了增强。 Christopher Trudeau 讨论了 Python 3.13 中提高局部命名空间一致性的改进,修复了一些与 locals() 函数相关的 bug。他还介绍了 argparse 库中新的弃用方法参数,以及对 doc test 的颜色编码支持。此外,他还提到了 Python 3.13 中对 breakpoint 和 set_trace 函数的改进,以及对标准库中一些未使用模块的移除。

Deep Dive

Shownotes Transcript

Python 3.13 is here! Our regular guests, Geir Arne Hjelle and Christopher Trudeau, return to discuss the new version. This year, Geir Arne coordinated a series of preview articles with members of the Real Python team and a showcase tutorial, “Python 3.13: Cool New Features for You to Try.” Christopher’s video course “What’s New in Python 3.13” covers the topics from the article and shows the new features in action.

Geir Arne and Christopher dug into the release to create code examples of the new features for the tutorial and course. We look at the options for disabling the Global Interpreter Lock (GIL) and enabling the Just-in-Time (JIT) compiler. We also discuss the new interactive interpreter, better error messages, multiple improvements to static typing, and additional performance improvements.

We share our thoughts on the updates and offer advice about incorporating them into your projects. We also discuss when you should start running Python 3.13.

This is episode is sponsored by Nvidia.

Course Spotlight: What’s New in Python 3.13)

In this video course, you’ll learn about the new features in Python 3.13. You’ll take a tour of the new REPL and error messages and see how you can try out the experimental free threading and JIT versions of Python 3.13 yourself.

Topics:

  • 00:00:00 – Introduction

  • 00:03:14 – A Modern REPL

  • 00:08:54 – Making the Global Interpreter Lock Optional in CPython

  • 00:11:33 – JIT Compilation

  • 00:15:48 – More improved error messages

  • 00:18:30 – Sponsor: NVIDIA

  • 00:19:13 – Marking deprecations using the type system

  • 00:21:09 – Type Defaults for Type Parameters

  • 00:22:44 – Narrowing types with TypeIs

  • 00:25:24 – TypedDict: Read-only items

  • 00:27:50 – Random command line interface

  • 00:29:54 – New copy.replace()

  • 00:33:43 – Video Course Spotlight

  • 00:34:55 – Pathlib and globbing

  • 00:39:33 – Stripping docstrings

  • 00:41:28 – Import improvements

  • 00:41:56 – Dynamically import non-code files

  • 00:42:23 – Adding iOS as a supported platform

  • 00:43:32 – More consistency with local namespace

  • 00:44:30 – Support for deprecation in argparse

  • 00:45:00 – Better entry points for breakpoint or set_trace

  • 00:46:08 – Removing dead batteries

  • 00:47:43 – When to upgrade to 3.13?

  • 00:53:19 – core.py podcast

  • 00:54:14 – Thanks and goodbye

Show Links:

Level up your Python skills with our expert-led courses:

Support the podcast & join our community of Pythonistas)