cover of episode #404 The Lost Episode

#404 The Lost Episode

2024/10/7
logo of podcast Python Bytes

Python Bytes

AI Deep Dive AI Chapters Transcript
People
B
Brian
Python 开发者和播客主持人,专注于测试和软件开发教育。
M
Michael
帮助医生和高收入专业人士管理财务的金融教育者和播客主持人。
Topics
Brian 详细介绍了 Python 3.13 的新特性,包括改进的 REPL 体验(例如 `exit` 命令的简化使用、多行编辑和历史记录保留、颜色支持等)、改进的错误消息以及对 free-threaded 模式的支持。他还提到了安装过程中需要手动启用 free-threaded 模式。 Michael 讨论了 PEP 759,该提案建议通过外部托管 wheel 文件来解决 PyPI 带宽问题和项目大小限制。他解释了新的 .rim 文件格式,以及为了确保安全性和稳定性而采取的措施,例如强制使用 HTTPS 和校验和。他还介绍了 pytest-freethreaded 插件,该插件用于测试代码在 Python 3.13 的 free-threaded 模式下的线程安全性,以及 pytest-edit 插件,该插件允许在测试失败时直接在编辑器中打开失败的测试代码。

Deep Dive

Chapters
This chapter covers the new features in Python 3.13, including improvements to the REPL, enhanced error messages, and the experimental free-threaded mode. The release was slightly delayed due to performance issues related to the incremental garbage collector.
  • Python 3.13.0 released on October 7th, 2024
  • Improved REPL experience with multiline editing, history preservation, and color support
  • Enhanced error messages providing better context for common issues
  • Experimental free-threaded CPython included in Windows and macOS installers (requires manual activation)
  • Release delayed due to performance issues with incremental GC

Shownotes Transcript

Topics covered in this episode:

- **[Python 3.13.0 released Oct 7](https://www.python.org/downloads/release/python-3130/?featured_on=pythonbytes))**

Watch on YouTube)

About the show

Sponsored by ScoutAPM: pythonbytes.fm/scout)

Connect with the hosts

Join us on YouTube at pythonbytes.fm/live) to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.

Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list), we'll never share it.

Brian #1: Python 3.13.0 released Oct 7)

  • That’s today!

  • What’s New In Python 3.13)

  • Interpreter (REPL) improvements

  • exit works (really, this is worth the release right here)

  • Multiline editing with history preservation.

  • history sticks around between sessions

  • Direct support for REPL-specific commands like help, exit, and quit, without the need to call them as functions.

  • Prompts and tracebacks with color enabled by default.

  • Interactive help browsing using F1 with a separate command history.

  • History browsing using F2 that skips output as well as the >>> and … prompts.

  • “Paste mode” with F3 that makes pasting larger blocks of code easier (press F3 again to return to the regular prompt).

  • exit now works without parens

  • Improved error messages

  • Colorful tracebacks

  • Better messages for

  • naming a script/module the same name as a stdlib module.

  • naming a script/module the same name as an installed third party module.

  • misspelling a keyword argument

  • Free threaded CPython

  • Included in official installers on Windows) and macOS)

  • Read these links to figure out how - it’s not turned on by default

  • Lot’s more. see the What’s new page

Michael #2: PEP 759 – External Wheel Hosting)

  • pypi.org ships over 66 petabytes / month) backed by Fastly

  • There are hard project size limits for publishers to PyPI

  • We can host the essence of a .whl as a .rim file, then allow an external download URL

  • Security: Several factors as described in this proposal should mitigate security concerns with externally hosted wheels, such as:

  • Wheel file checksums MUST be included in .rim files, and once uploaded cannot be changed. Since the checksum stored on PyPI is immutable and required, it is not possible to spoof an external wheel file, even if the owning organization lost control of their hosting domain.

  • Externally hosted wheels MUST be served over HTTPS.

  • In order to serve externally hosted wheels, organizations MUST be approved by the PyPI admins.

Brian #3: pytest-freethreaded)

  • PyCon JP 2024 Team:

  • This extension was created at PyCon JP sprints with Anthony Shaw and 7 other folks listed in credits.)

  • “A pytest plugin for helping verify that your tests and libraries are thread-safe with the Python 3.13 experimental freethreaded mode.”

  • Testing your project for compatibility with freethreaded Python.

  • Testing in single thread doesn’t test that.

  • Neither does testing with pytest-xdist, because it uses multiprocessing to parallelize tests.

  • So, Ant and others “made this plugin to help you run your tests in a thread-pool with the GIL disabled, to help you identify if your tests are thread-safe.”

  • “And the first library we tested it on (which was marked as compatible) caused a segmentation fault in CPython! So you should give this a go if you're a package maintainer.”

Michael #4: pytest-edit)

  • A simple Pytest plugin for opening editor on the failed tests.

  • Type pytest --edit to open the failing test code sparkles

  • Be sure to set your favorite editor in the ENV variables

Extras

Michael:

Joke: Funny 404 pages)