为什么 Callable ABC 在 collections ABC 模块中?

Why is the Callable ABC in the collections ABC module?

Python collections.abc module contains many handy ABCs for checking various features of objects, but one that doesn't appear to belong is Callable. No standard collection is callable, and PEP 3119 没有提供任何推理,甚至没有提到 Callable ABC,那么为什么它在这个包中而不是其他地方?

上下文: 我写一个 Python->Java 编译器是为了好玩,我只是想看看这个决定背后是否有任何理由,这样我就可以在我的代码中列出这个理由。

该模块源自 PEP-3119,它提出:

Specific ABCs for containers and iterators, to be added to the collections module.

但从那以后,它演变成了更多的东西。现在模块描述没有明确提及容器和迭代器。它说:

This module provides abstract base classes that can be used to test whether a class provides a particular interface; for example, whether it is hashable or whether it is a mapping.

我相信它是一个 collections 子模块,因为它过去是它的一部分:

New in version 3.3: Formerly, this module was part of the collections module.