On Oct 14, 2019, at 13:28, Steve Jorgensen
Andrew Barnert wrote:
On Oct 14, 2019, at 07:15, Steven D'Aprano steve@pearwood.info wrote: Speaking of UserString, does anyone know why it isn't registered as a virtual subclass of str? None of the concrete classes register virtual subclasses, so this would be a unique exception.
See the final lines in https://github.com/python/cpython/blob/3.7/Lib/_collections_abc.py
MutableSequence.register(list) MutableSequence.register(bytearray) # Multiply inheriting, see ByteString
But that’s the exact opposite: it registers list and bytearray as virtual subclasses of the ABC MutableSequence, it doesn’t register MutableSequence as a virtual subclass of the concrete classes list and bytearray. Doing the latter would not only (like Steven’s proposal) be unprecedented and require changes to builtin types, but also (completely unlike Steven’s proposal) be just wrong—it’s certainly not true in any useful sense that every mutable sequence is usable as a bytearray.