From 27b53a0429348566208d953a6b36f63928757927 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 5 Sep 2025 21:55:49 +0100 Subject: [PATCH 1/2] Remove ``sort()`` from the common sequence methods in the data model --- Doc/reference/datamodel.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index ba0071631adfc0..6b495506ef0254 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -3145,8 +3145,7 @@ objects. The :mod:`collections.abc` module provides a Mutable sequences should provide methods :meth:`~sequence.append`, :meth:`~sequence.count`, :meth:`~sequence.index`, :meth:`~sequence.extend`, :meth:`~sequence.insert`, :meth:`~sequence.pop`, :meth:`~sequence.remove`, -:meth:`~sequence.reverse` and :meth:`~sequence.sort`, -like Python standard :class:`list` objects. +and :meth:`~sequence.reverse`, like Python standard :class:`list` objects. Finally, sequence types should implement addition (meaning concatenation) and multiplication (meaning repetition) by defining the methods :meth:`~object.__add__`, :meth:`~object.__radd__`, :meth:`~object.__iadd__`, From 73d3442d4758711de4fe53335a84decb485a4cec Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 10 Sep 2025 02:58:54 +0100 Subject: [PATCH 2/2] Add `clear()` --- Doc/reference/datamodel.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 6b495506ef0254..262e9501bc133a 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -3142,16 +3142,20 @@ objects. The :mod:`collections.abc` module provides a :term:`abstract base class` to help create those methods from a base set of :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, :meth:`~object.__delitem__`, and :meth:`!keys`. -Mutable sequences should provide methods :meth:`~sequence.append`, -:meth:`~sequence.count`, :meth:`~sequence.index`, :meth:`~sequence.extend`, -:meth:`~sequence.insert`, :meth:`~sequence.pop`, :meth:`~sequence.remove`, -and :meth:`~sequence.reverse`, like Python standard :class:`list` objects. + +Mutable sequences should provide methods +:meth:`~sequence.append`, :meth:`~sequence.clear`, :meth:`~sequence.count`, +:meth:`~sequence.extend`, :meth:`~sequence.index`, :meth:`~sequence.insert`, +:meth:`~sequence.pop`, :meth:`~sequence.remove`, and :meth:`~sequence.reverse`, +like Python standard :class:`list` objects. Finally, sequence types should implement addition (meaning concatenation) and multiplication (meaning repetition) by defining the methods :meth:`~object.__add__`, :meth:`~object.__radd__`, :meth:`~object.__iadd__`, :meth:`~object.__mul__`, :meth:`~object.__rmul__` and :meth:`~object.__imul__` described below; they should not define other numerical -operators. It is recommended that both mappings and sequences implement the +operators. + +It is recommended that both mappings and sequences implement the :meth:`~object.__contains__` method to allow efficient use of the ``in`` operator; for mappings, ``in`` should search the mapping's keys; for sequences, it should