Pythonのdataclassesについて少し調べた

Pythonのdataclassesのコードリーティングをしてみようと以下のGitリポジトリは読んでいました。

github.com

しかし、READMEをよく見てみると以下のように書かれていました。

This is an implementation of PEP 557, Data Classes. It is a backport for Python 3.6. Because dataclasses will be included in Python 3.7, any discussion of dataclass features should occur on the python-dev mailing list at https://mail.python.org/mailman/listinfo/python-dev. At this point this repo should only be used for historical purposes (it's where the original dataclasses discussions took place) and for discussion of the actual backport to Python 3.6.

backportという単語が初めてみたので調べたところ、

バックポート(backporting)とは、ソフトウェアの新しいバージョンの機能や、そのバージョン向けに開発されたプログラムなどを、古いバージョンで利用できるように移植すること。

ということのようでした。

e-words.jp

なので、READMEの内容としては、以下だと解釈しました。

  • Data ClassesはPEP557で実装されたものでPython 3.7からPythonで特にライブラリをインストールしなくても使える
  • dataclassの機能に関する議論はpython-devメーリングリストで行う
  • このリポジトリは過去の記録を振り返る用途で使われる

Python3.7以降のdataclassesのコードはどこにあるのか調べたところ、cpython/Lib/dataclasses.pyに上記のリポジトリとほぼ同じコードがあるように見えました。

github.com

つまり、dataclassはPython3.6以前はライブラリをインストールしないと使えなかったけど、Python3.7以降はPythonの標準機能として使えるという理解で良いのかが確信が持てなかったのでChatGPTに質問したところ以下の答えが帰ってきました。

Yes, you're correct in noting that the concept of Python's dataclasses module initially started as an external, open-source project before becoming part of the standard library. This is a common pathway for new features in Python, where they are first developed and matured outside the standard library.

概ね理解としては合っているようでした。また、Pythonの新機能が追加される時に最初は外部のライブラリとして開発されて後から標準機能になる流れが一般的とのことでした。