[issue33519] Should MutableSequence provide .copy()?

Serhiy Storchaka report at bugs.python.org
Tue May 15 15:07:54 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

MutableSequence defines an interface. Adding a new method will break all classes that implemented this protocol but not the new method.

And what should .copy() return? list subclasses return an exact list, bytearray subclasses return an exact bytearray, but deque subclasses try to create an instance of the same type. Not all mutable sequences can be copyable. The constructor is not the part of the protocol.

The same problems are in MutableSet and MutableMapping. This is why they don't provide copy() methods (but concrete classes set and dict do).

----------
nosy: +serhiy.storchaka

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


More information about the Python-bugs-list mailing list