nikkie-ftnextの日記

イベントレポートや読書メモを発信

Pythonは常に機能が拡充している!この10月に出た3.13で失ったものなど、何一つない! ― ◯か☓か

2024年10月にPython 3.13.0がリリースされました。

3.13.0 final: Monday, 2024-10-07

Pythonはマイナーバージョンアップで機能追加されており、3.13でも新機能が追加されています1
https://docs.python.org/ja/3.13/whatsnew/3.13.html
ですが、実は失われたものもあるという話をしていきます(タイトルへの回答は ☓ 🙅‍♀️ぶっぶーですわ

目次

PEP 594 – Removing dead batteries from the standard library

標準ライブラリから古い19のモジュールが削除されているのです!

https://docs.python.org/ja/3.13/whatsnew/3.13.html#pep-594-remove-dead-batteries-from-the-standard-library

PEP 594 proposed removing 19 modules from the standard library, colloquially referred to as 'dead batteries' due to their historic, obsolete, or insecure status. All of the following modules were deprecated in Python 3.11, and are now removed:

この削除は3.13で突然起こったものではなく、3.11でdeprecateされていました。
https://docs.python.org/ja/3.13/whatsnew/3.11.html#modules

PEP 594 led to the deprecations of the following modules slated for removal in Python 3.13:

(19のモジュールが表で示されています)

Python 3.13で削除されたモジュールの1つ:aifc

docs.python.org

このモジュールはAIFFAIFF-Cファイルの読み書きをサポートします。AIFF(Audio Interchange File Format)はデジタルオーディオサンプルをファイルに保存するためのフォーマットです。

削除理由はPEPにあります。
https://peps.python.org/pep-0594/#aifc
ここを読んだ理解なのですが、削除理由は以下

  • AIFF形式を利用するアプリケーションが今となっては限られる2
  • AIFFAIFF-Cファイルの形式は安定しており、aifcモジュールは多くのメンテナンスを必要としない3

Pythonのドキュメント側には「取って代わられたモジュール群」というページがあり、そこからaifcなどがリンクされています

docs.python.org

PEP 594関連の議論を追う

aifcも取って代わられたモジュールの1つなので、何に取って代わられたのか知ろうとdiscussを覗きました。

すべてを読み切れてはいないのですが、その中で見つけたのは別のスレッド

I think both the aifc and the chunk module deserve a reevaluation under PEP 594. (Marc-André Lemburg)4

ここが結論なのかな
https://discuss.python.org/t/maintaining-the-chunk-module-after-it-has-been-removed-from-the-standard-library/38177/41

Exciting News on the Chunk Module:

I’m thrilled to announce that the chunk module now includes tests. It’s currently a single test, but as someone new to writing publicly accessible tests (略)

Upcoming Planの中に「Integration with the AIFC Module

chunkモジュールは「EA IFF 85チャンクを使用しているファイルの読み込みのためのインターフェースを提供します。

廃止理由
https://peps.python.org/pep-0594/#chunk

IFF is an old audio file format originally introduced for Commodore and Amiga. The format is no longer relevant.

chunkモジュール廃止の再考スレッドはこちら

終わりに

Python 3.13でaifcやchunkといったモジュールが標準ライブラリから削除されていたことを知りました。
メンテナンスするコストが価値に見合わない古いモジュールは削除する提案をして、削除していく動きは素晴らしいものだと思います(議論の過程が公開されていることも!)。
ありがとうございます!

なお、私がPEP 594によるPython 3.13での削除に気づいたのは、メンテしているSpeechRecognitionへのissueがきっかけでした5

教えていただきありがとうございます。
aifcが何に取って代わられたのかは見つけられていないのですが、対応を進めています(詳細はまた別の記事で)。
ですが、このあたり経験がなく不安ではあるので、知見のある方がいたら対応へのご意見伺いたいです。お知らせください!


  1. The biggest changes include a new interactive interpreter, experimental support for running in a free-threaded mode (PEP 703), and a Just-In-Time compiler (PEP 744).」(What's New In Python 3.13) Global Interpreter LockがないPythonが、来ました!
  2. These days only few specialized application use AIFF.
  3. The file format is stable and the module does not require much maintenance.
  4. https://discuss.python.org/t/maintaining-the-chunk-module-after-it-has-been-removed-from-the-standard-library/38177/3
  5. この間distutilsとお別れしたと思ったら...