[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

Raymond Hettinger report at bugs.python.org
Sun Oct 4 14:43:39 EDT 2020


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

> How so?

When a concrete class registers with an ABC, it is making a promise that it implements everything in the ABC so that client code can count on all the methods being present.  That is the raison d'etre for abstract base classes.

In general, we restrict ABCs to a minimal useful subset of the capabilities of concrete classes.  That makes the ABC more broadly applicable and it makes life easier for implementers of concrete classes.  That's why collections.abc.Set doesn't include most of the named methods present in the concrete set/frozenset types.

Likewise, we don't want to add methods to already published ABCs because existing user classes registered to the ABC stop being compliant.  If an additional method is deemed essential, the technically correct way to do is to make a new ABC that subclasses from the old.  For example, that's why Python 2 had to have both UserDict and IterableUserDict when we needed to add a __iter__() method.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue26680>
_______________________________________


More information about the Python-bugs-list mailing list