[stdlib-sig] Where should be put ABCs?

Brett Cannon brett at python.org
Thu Dec 3 20:27:16 EST 2015


In http://bugs.python.org/issue25609 I said I wanted an ABC for context
managers and a matching entry in typing. I originally suggested putting it
in collections.abc <https://docs.python.org/3/library/collections.abc.html>
but Raymond Hettinger pointed out that it doesn't really belong there
(along with a bunch of other ABCs like Callable and Awaitable).

So I opened http://bugs.python.org/issue25637 to discuss this, but I
realize maybe this SIG is a better place to have a real discussion. The
options I see are:

   1. Ignore Raymond's objection and put it in collections.abc
   2. Stick it in contextlib
   <https://docs.python.org/3/library/contextlib.html>
      1. Directly
      2. In a new contextlib.abc submodule
   3. Stick in abc <https://docs.python.org/3/library/abc.html>
      1. Directly
      2. In some new subclass like abc.interfaces

Do people have any thoughts on this? Whatever decision we make in this
instance should probably apply to the other misplaced ABCs in
collections.abc (e.g., should Callable go into functools somehow, into
abc?).

Yury Selivanov voted for putting them in abc directly since having to
always try and find a proper module to put  the abc might not always work,
and so putting the concrete interface ABCs that directly define what
Python's syntactic sugar and interpreter rely on made sense. Terry Reedy
even suggested that collections.abc was a mistake and should have been made
abc.collections (which wouldn't be hard  due  to how all the relevant code
for collections.abc is in Lib/_collection_abc.py and hence already in an
odd place).

I'm a little partial to putting the ABCs in relevant modules like functools
and contextlib, but otherwise I think abc makes sense.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/stdlib-sig/attachments/20151204/3c312934/attachment.html>


More information about the stdlib-sig mailing list