From df5121b633b079f27d3de096cfb7e994a8955f18 Mon Sep 17 00:00:00 2001 From: Julian Soreavis <263610811+soreavis@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:31:47 +0200 Subject: [PATCH] gh-61481: Document that memoryview, range, and slice cannot be subclassed Among the built-in classes that can't be subclassed, only bool documents it. memoryview, range, and slice behave the same but say nothing, so it can only be found out by trying. Add the same note to those three. The wording mirrors the existing bool entry, minus the "further" that applies only to bool (which subclasses int). --- Doc/library/functions.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index a4d37beb436899a..6404d7f17017533 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1292,6 +1292,8 @@ are always available. They are listed here in alphabetical order. Return a "memory view" object created from the given argument. See :ref:`typememoryview` for more information. + This class cannot be subclassed. + .. function:: min(iterable, /, *, key=None) min(iterable, /, *, default, key=None) @@ -1749,6 +1751,8 @@ are always available. They are listed here in alphabetical order. Rather than being a function, :class:`range` is actually an immutable sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`. + This class cannot be subclassed. + .. function:: repr(object, /) @@ -1920,6 +1924,8 @@ are always available. They are listed here in alphabetical order. See :func:`itertools.islice` for an alternate version that returns an :term:`iterator`. + This class cannot be subclassed. + .. attribute:: slice.start slice.stop slice.step